还不知道是哪里的题目。。

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

今天比赛的一道题,队友A的,做法就是将字母存到整型数组里面。然后排序,从后面开始判断,如果有相等的,就不是,如果全都不相等,则加一。。以下是代码

#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <cmath>
#include <string.h>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#define max 1000010
int main ()
{
    int a,b,i,j,k,m,p=1;
    int s[40];
    char str[40];
    while(scanf("%d",&a)!=EOF)
	{
		m=0;
		while(a--)
		{
			memset(s, 0, sizeof(s));
			scanf("%s",str);
			if(strlen(str)==1)
				continue;
			for(i=0;i<strlen(str);i++)
			{
				b=str[i]-'a';
				s[b]++;
			}
			sort(s,s+40);
			if(s[39]==strlen(str))
				continue;
			for(k=1,j=39;s[j]!=0;j--)
			{
				if(s[j]==s[j-1])
					k=0;
			}
			if(k==1)
				m=m+1;
		}
		printf("Case %d: %d\n",p++,m);
	}
    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值