计算机学院大学生程序设计竞赛(2015’12)The Country List
来源:互联网 发布:福州seo短期培训 编辑:程序博客网 时间:2024/05/24 05:05
The Country List
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2464 Accepted Submission(s): 576
Problem Description
As the 2010 World Expo hosted by Shanghai is coming, CC is very honorable to be a volunteer of such an international pageant. His job is to guide the foreign visitors. Although he has a strong desire to be an excellent volunteer, the lack of English makes him annoyed for a long time.
Some countries’ names look so similar that he can’t distinguish them. Such as: Albania and Algeria. If two countries’ names have the same length and there are more than 2 same letters in the same position of each word, CC cannot distinguish them. For example: Albania and AlgerIa have the same length 7, and their first, second, sixth and seventh letters are same. So CC can’t distinguish them.
Now he has received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters are case-insensitive.
Some countries’ names look so similar that he can’t distinguish them. Such as: Albania and Algeria. If two countries’ names have the same length and there are more than 2 same letters in the same position of each word, CC cannot distinguish them. For example: Albania and AlgerIa have the same length 7, and their first, second, sixth and seventh letters are same. So CC can’t distinguish them.
Now he has received a name list of countries, please tell him how many words he cannot distinguish. Note that comparisons between letters are case-insensitive.
Input
There are multiple test cases.
Each case begins with an integer n (0 < n < 100) indicating the number of countries in the list.
The next n lines each contain a country’s name consisted by ‘a’ ~ ‘z’ or ‘A’ ~ ‘Z’.
Length of each word will not exceed 20.
You can assume that no name will show up twice in the list.
Each case begins with an integer n (0 < n < 100) indicating the number of countries in the list.
The next n lines each contain a country’s name consisted by ‘a’ ~ ‘z’ or ‘A’ ~ ‘Z’.
Length of each word will not exceed 20.
You can assume that no name will show up twice in the list.
Output
For each case, output the number of hard names in CC’s list.
Sample Input
3DenmarkGERMANYChina4AaaaaBaacBaacBad
Sample Output
24
#include <stdio.h>#include <stdlib.h>#include <string.h>int da[105]= {0};void bijiao(int n,char c[105][30]){ int i,j,t=0,q; for(i=0; i<n; i++) for(j=0; j<n; j++) { t=0; if(strcmp(c[i],c[j])==0)continue; if(strlen(c[i])==strlen(c[j])) { for(q=0; q<(int)strlen(c[i]); q++) { if(c[i][q]==c[j][q])t++; } if(t>2) { da[i]=1; da[j]=1; } } }}void xiaoxie(char c[30]){ int n=strlen(c),i; for(i=0; i<n; i++) { if(c[i]>='A'&&c[i]<='Z')c[i]+=32; }}int main(){ int n,i,j; char c[105][30]; while(~scanf("%d",&n)&&n) { j=0; getchar(); for(i=0; i<n; i++)da[i]=0; for(i=0; i<n; i++) { gets(c[i]); xiaoxie(c[i]); } bijiao(n,c); for(i=0; i<n; i++)j+=da[i]; printf("%d\n",j); } return 0;}
1 0
- hdu 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
- 计算机学院大学生程序设计竞赛(2015’12)The Country List(水题)
- 计算机学院大学生程序设计竞赛(2015’12)1001 The Country List
- 计算机学院大学生程序设计竞赛(2015’12)(STL )
- 计算机学院大学生程序设计竞赛(2015’12)Polygon
- 计算机学院大学生程序设计竞赛(2015’12)Happy Value
- 计算机学院大学生程序设计竞赛(2015’12)Bitwise Equations
- 计算机学院大学生程序设计竞赛(2015’12)01 Matrix
- 计算机学院大学生程序设计竞赛(2015’12)Pick Game
- 计算机学院大学生程序设计竞赛(2015’12)Study Words
- 计算机学院大学生程序设计竞赛(2015’12)Bitwise Equations
- 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower(水~~~)
- hdu 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower
- 计算机学院大学生程序设计竞赛(2015’12)The collector’s puzzle
- 计算机学院大学生程序设计竞赛(2015’12)The Magic Tower
- 计算机学院大学生程序设计竞赛(2015’12)The collector’s puzzle
- 计算机学院大学生程序设计竞赛(2015’12)1009 The Magic Tower
- Android实现短信验证功能(使用前的准备)
- 填充ListView(使用SimpleAdapter)
- Linux安装Redis
- javascript冒泡排序
- 嵌入式audio基础(五)性能指标补遗
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
- iOS 从相册加载图片到imageview
- android 学习之触摸事件 -- 事件派发
- 如何利用matlab爬虫抓数据
- 编程语言特性总结
- 软件定义和硬件重构知多少(三)
- UNITY 位移
- freetype2 编译
- 【GLSL教程】(八)纹理贴图