Title Link: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=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
HINT
Source
The tenth session of Hunan Province College students computer Program design Contest
The code is as follows:
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;int main () { int n; Char s[10017]; int a[27]; int cas = 0; while (~SCANF ("%d", &n)) { int k = 0; for (int i = 0; i < n; i++) { memset (a,0,sizeof (a)); scanf ("%s", s); int len = strlen (s); if (len = = 1) continue; for (int j = 0; J < Len; j + +) { a[s[j]-' a ']++; } Sort (a,a+26); int l; for (L = 1; l <, l++) { if (a[l] = = a[l-1] && a[l]!= 0) break ; if (L = =) k++; } printf ("Case%d:%d\n", ++cas,k); } return 0;}
CSU 1505: Cool words (math AH)