CSU 1505: Cool words (math AH)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.