• CSU 1505 酷酷的单词 湖南省赛第十届题目


    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505

    题意:技巧题,就是一行字符串中,每个字母出现的次数互不相同,复即为酷的单词。

    解题思路:看看题意,再结合案例,就能明白了只需要对字符串中的每个字符进行统计个数就行。

    AC代码:

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    using namespace std;
    const int M=26+5;
    int n,ans,a[M],b[M];
    char s[M];
    int main()
    {
      int n,ca=1;
      while(scanf("%d",&n)==1)
      {
        ans=0;
        for(int i=0;i<n;i++)
        {
          memset(a,0,sizeof(a));
          memset(b,0,sizeof(b));
          int f=1;
          scanf("%s",s);
          int len=strlen(s);
          if(len==1) continue;
          for(int j=0;j<len;j++)  a[s[j]-'a']++;
          for(int j=0;j<26;j++)
            {
             if(a[j]) b[a[j]]++;
             if(b[a[j]]>1){ f=0;break;}
            }
            if(f) ans++;
          }
        printf("Case %d: %d
    ",ca++,ans);
      }
      return 0;
    }
  • 相关阅读:
    HDU 3709 Balanced Number
    HDU 3652 B-number
    HDU 3555 Bomb
    全局和局部内存管理
    [转]
    [转]
    [转]
    The Stable Marriage Problem
    STL各种容器的使用时机详解
    Qt中图像的显示与基本操作
  • 原文地址:https://www.cnblogs.com/www-cnxcy-com/p/5740822.html
Copyright © 2020-2023  润新知