博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
The Country List
阅读量:6072 次
发布时间:2019-06-20

本文共 5249 字,大约阅读时间需要 17 分钟。

The Country List

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 0    Accepted Submission(s): 0

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.
 

 

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.
 

 

Output
For each case, output the number of hard names in CC’s list.
 

 

Sample Input
3 Denmark GERMANY China 4 Aaaa aBaa cBaa cBad
 

 

Sample Output
2 4
 
 
#include 
#include
char str[101][21];int vis[101];int main(){ int t; while(scanf("%d", &t)!= EOF){ int sum = 0; memset(vis, 0, sizeof(vis)); for(int i = 0; i < t; i++){ scanf("%s", str[i]); for(int k = 0; k < strlen(str[i]); k++) if(str[i][k] >= 'A' && str[i][k] <= 'Z') str[i][k] = str[i][k] + 32; } for(int i = 0; i < t; i++){ int G = 0; for(int j = 0; j < t; j++){ int cnt = 0; int a = strlen(str[i]); int b = strlen(str[j]); if(a == b){ for(int k = 0, f = 0; f < b; f++, k++) if(str[i][k] == str[j][f]) cnt++; if(cnt > 2 && cnt != a) G++; } if(G) break; } if(G) vis[i] = 1; } for(int i = 0; i < t; i++){ if(vis[i]) sum++; } printf("%d\n", sum); } return 0;}

 

 

The Magic Tower

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0
Problem Description
Like most of the RPG (role play game), “The Magic Tower” is a game about how a warrior saves the princess.
After killing lots of monsters, the warrior has climbed up the top of the magic tower. There is a boss in front of him. The warrior must kill the boss to save the princess.
Now, the warrior wants you to tell him if he can save the princess.
 
Input
There are several test cases.
For each case, the first line is a character, “W” or “B”, indicating that who begins to attack first, ”W” for warrior and ”B” for boss. They attack each other in turn.
The second line contains three integers, W_HP, W_ATK and W_DEF. (1<=W_HP<=10000, 0<=W_ATK, W_DEF<=65535), indicating warrior’s life point, attack value and defense value.
The third line contains three integers, B_HP, B_ATK and B_DEF. (1<=B_HP<=10000, 0<=B_ATK, B_DEF<=65535), indicating boss’s life point, attack value and defense value.
Note: warrior can make a damage of (W_ATK-B_DEF) to boss if (W_ATK-B_DEF) bigger than zero, otherwise no damage. Also, boss can make a damage of (B_ATK-W_DEF) to warrior if (B_ATK-W_DEF) bigger than zero, otherwise no damage.
 
Output
For each case, if boss’s HP first turns to be smaller or equal than zero, please print ”Warrior wins”. Otherwise, please print “Warrior loses”. If warrior cannot kill the boss forever, please also print ”Warrior loses”.
 
Sample Input
W 100 1000 900 100 1000 900 B 100 1000 900 100 1000 900
 
Sample Output
Warrior wins Warrior loses
 
//相死, 攻击和护盾是定值, 用数组!!!!!
 
#include 
int main(){ char ch[10]; while(scanf("%s", ch)){ /*************************/ int a, b, c, d, e, f; scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f); if(b-f <= 0 && e-c <= 0){ printf("Warrior loses\n"); continue; } if(ch == 'W'){ while(1){ d -= b-f; if(d <= 0) break; a -= e-c; if(a <= 0) break; } } else{ while(1){ a -= e-c; if(a <= 0) break; d -= b-f; if(d <= 0) break; } } if(d <= 0) printf("Warrior wins\n"); if(a <= 0) printf("Warrior loses\n"); } return 0;}

 

 

转载于:https://www.cnblogs.com/soTired/p/5078288.html

你可能感兴趣的文章
PAT 1003. Emergency
查看>>
三星i9300 unroot || root恢复
查看>>
jsp基础知识
查看>>
离线安装db2的python模块ibm_db
查看>>
环境变量
查看>>
Swift 项目中可能用到的第三方框架
查看>>
我的友情链接
查看>>
普通exe和sys驱动文件结构上有什么不同?
查看>>
Shell脚本查看apk签名信息
查看>>
raid数据恢复,Raid5磁盘阵列数据恢复案例,服务器数据恢复
查看>>
Active Directory授权还原
查看>>
双因素方差分析
查看>>
Skype for Business Server 2015 后端数据库配置镜像见证(mirroring witness)
查看>>
Exchange Server 2013安装(为和Lync Server 2013集成做准备)
查看>>
关于光标属性cursor
查看>>
IIS6.0环境php5.3.6配置
查看>>
智力面试题
查看>>
我的友情链接
查看>>
Web Service 之 http(一)
查看>>
微软认罚不会上诉
查看>>