酷酷的单词

来源:互联网 发布:windows bat 输入密码 编辑:程序博客网 时间:2024/05/16 18:58


输入一些仅由小写字母组成的单词。你的任务是统计有多少个单词是“酷”的,即每种字母出现的次数都不同。
比如ada是酷的,因为a出现2次,d出现1次,而1和2不同。再比如,banana也是酷的,因为a出现3次,n出现2次,b出现1次。但是,bbacccd不是酷的,因为a和d出现的次数相同(均为1次)。

Input

输入包含不超过30组数据。每组数据第一行为单词个数n (1<=n<=10000)。以下n行各包含一个单词,字母个数为1~30。

Output

对于每组数据,输出测试点编号和酷单词的个数。

Sample Input
2adabbacccd2illnessa
Sample Output
Case 1: 1Case 2: 0


#include<iostream>#include<string.h>#include<stdio.h>#include<algorithm>#include<set>using namespace std;int main(){    int n, j = 0;    set<int> m;    set<char> s;    char ch[30];    int num[26];    while(cin>>n)    {        int ans = 0;        while(n--)        {            m.clear();            s.clear();            cin>>ch;            int x;            memset(num, 0, sizeof(num));            for(int i = 0; i < strlen(ch); i++)            {                s.insert(ch[i]);                num[ch[i]-97]++;            }            x = s.size();            for(int i = 0; i < 26; i++)            {                if(num[i] != 0)                    m.insert(num[i]);            }            if(x != 1)            {                if(x == m.size())                    ans++;            }        }        cout<<"Case "<<++j<<": "<<ans<<endl;    }    return 0;}





0 0
原创粉丝点击