1505: Cool Words
Time limit:1 Sec Memory limit:128 MB
submit:237 solved:88
[Submit] [Status] [Web Board]
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
2
Ada
Bbacccd
2
Illness
A
Sample Output
Case 1:1
Case 2:0
HINT
Source
The tenth session of Hunan Province College students computer Program design Contest
Provincial game check-in question, mainly a string of some operations, basically did not involve any algorithm, read test instructions can do, the title means that the statistics given the number of words in the word are different words, if the word has only one letter, it is considered the same.
#include <iostream>#include <cstdio>#include <cstring>using namespace STD;intMain () {intn,len,count,flag,k=1;Chars[ +];inta[ -]; while(scanf("%d", &n)!=eof) {count=0; while(n--) {flag=1;memsetA0,sizeof(a));scanf('%s ', s); len=strlen(s); for(intI=0; i<len; i++) {a[s[i]-' A ']++;//Count the number of occurrences of word letters} for(intI=0; i< -; i++) { for(intj=i+1; j< -; J + +) {if(a[i]==a[j]&&a[i]!=0) {flag=0; Break; } } }if(flag==1&&len!=1) {count++; } }printf("Case%d:%d\n", K++,count); }return 0;}
The tenth session of Hunan Province College students computer Program design competition: Cool words