CSU 1505: 酷酷的单词(数学啊)
来源:互联网 发布:闲鱼淘宝二手能退货吗 编辑:程序博客网 时间:2024/06/04 08:35
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1505
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
2adabbacccd2illnessa
Sample Output
Case 1: 1Case 2: 0
HINT
Source
湖南省第十届大学生计算机程序设计竞赛
代码如下:
#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 < 26; l++) { if(a[l] == a[l-1] && a[l]!= 0) break; } if(l == 26) k++; } printf("Case %d: %d\n",++cas,k); } return 0;}
1 0
- CSU 1505: 酷酷的单词(数学啊)
- CSU 1505 酷酷的单词
- CSU 1505 酷酷的单词 【水题】
- CSU OJ 1505: 酷酷的单词
- CSU 1505 酷酷的单词 (简单题)
- ACM--酷酷的单词--CSU 1505--湖南第十届省赛
- CSU 1505——酷酷的单词
- CSU 1505 酷酷的单词_水题
- CSU 1506 酷酷的单词
- CSU 1409: 集合的并(数学啊 )
- CSU 1407: 最短距离(数学啊 )
- CSU 1410: 整数转换(数学啊 )
- CSU 1265: Dice (数学啊 )
- CSU 1270: Swap Digits(数学啊 )
- CSU 1271: Brackets Sequence(数学啊 )
- csu 1759 Triangle(数学)
- CSU 1507: 超大型LED显示屏(数学啊)
- CSU 1266: Divisible by 11 (数学啊 )
- 将InputStream流装换成String字符串
- Python – __all__ function
- 2015 CVTE校招网测部分试题(技术类)
- POJ Ubiquitous Religions (并查集)
- kafka运行环境优化分析
- CSU 1505: 酷酷的单词(数学啊)
- LeetCode-----Linked List Cycle
- storm 启动异常 Error when processing event
- 指针与多维数组(1)12.6
- poj2139 Six Degrees of Cowvin Bacon(Flyod)
- (SRC)基于稀疏表示的人脸识别
- 导航栏、状态栏设置
- DM642程序固化方法总结
- C语言基础之函数、内存剖析及位运算符