B-Cool wordsTime
limit:1000MS
Memory Limit:131072KB
64bit IO Format:%lld &%llu CSU 1505
Description
Enter some words that consist only of lowercase letters. Your task is to count how many words are "cool", that is, each letter appears in a different number of times.
Ada is cool, for example, because a appears 2 times, D appears 1 times, and 1 and 2 are different. For example, banana is also cool, because a appears 3 times, N appears 2 times, B appears 1 times. However, BBACCCD is not cool because A and d appear the same number of times (both are 1).
Input
The input contains no more than 30 sets of data. Number of first behavior words n (1<=n<=10000) for each set of data. The following n lines contain a single word, with the number of letters 1~30.
Output
For each set of data, output the number of test points and the number of cool words.
Sample Input
2adabbacccd2illnessa
Sample Output
Case 1:1case 2:0
Simple topic, but pay attention to AAA is not "cool"
1#include <stdio.h>2#include <string.h>3 4 Charstr[ +];5 intch[ -];//Number of letters6 BOOLtimes[ +];//the number of letters7 8 intMain ()9 {Ten intI,n,case=0; One while(SCANF ("%d", &n)! =EOF) A { - intans=0; - while(n--) the { -scanf"%s", str); -memset (CH,0,sizeof(CH)); - intlen=strlen (str); + - for(i=0; i<len;i++)//Count +ch[str[i]-'a']++; A atMemset (Times,0,sizeof(Times)); - intok=1; - intnum=0; - for(i=0;i< -; i++) - { - if(ch[i]!=0) num++; in if(ch[i]!=0&& times[ch[i]]==0) -times[ch[i]]=1; to Else if(ch[i]!=0&& times[ch[i]]==1)//as long as there is the same number of letters + { -ok=0; the Break; * } $ }Panax Notoginseng if(ok&&num!=1) -ans++; the } +printf"Case %d:%d\n",++Case,ans); A } the return 0; +}
View Code
B-Cool words