Time Limit: 1 Sec Memory Limit: 128 MB
Description
输入一些仅由小写字母组成的单词。你的任务是统计有多少个单词是“酷”的,即每种字母出现的次数都不同。
比如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
2
ada
bbacccd
2
illness
a
Sample Output
Case 1: 1
Case 2: 0
1 #include <stdio.h>
2 #include <string.h>
3
4 int main(){
5 int ct[255],ft[40],k=0,n;
6 char tmp[40];
7 //freopen("1505.in","r",stdin);
8 while(scanf("%d",&n) == 1){
9 int count = 0;
10 while(n--){
11 int i,j,len;
12 scanf("%s",tmp);
13 len = strlen(tmp);
14 memset(ct,0,sizeof(ct));
15 memset(ft,0,sizeof(ft));
16 for(i=0;i<len;i++){
17 ct[tmp[i]]++;
18 }
19 for(i=0;i<255;i++){
20 if(ct[i] != 0){
21 ft[ct[i]]++;
22 }
23 }
24 int flag = 0,t=0;
25 for(i=0;i<40;i++){
26 if(ft[i]==1) t++;
27 if(ft[i]>1){
28 // bu ku
29 flag = 1;
30 break;
31 }
32 }
33 if(!flag && t!=1){
34 count++;
35 }
36 }
37 printf("Case %d: %d\n",++k,count);
38 }
39 return 0;
40 }