URAL 1612. Tram Forum(字符串啊 )
来源:互联网 发布:linux怎么ping 编辑:程序博客网 时间:2024/06/05 14:15
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1612
1612. Tram Forum
Time limit: 0.5 second
Memory limit: 64 MB
Memory limit: 64 MB
Tram, trolleybus, and bus drivers talk at the tram forum. We have read all messages posted at the forum during last month and discovered an interesting rule. Users in whose messages the word “tram” occurs more often than the word “trolleybus” are tram drivers. Similarly, users in whose messages the word “trolleybus” is more frequent than the word “tram” are trolleybus drivers. All other users of the tram forum are bus drivers. Given this information, can you determine who has posted the latest message at the tram forum?
Input
You are given the latest message at the tram forum. The message consists of lowercase English letters, spaces, line breaks, and punctuation marks: periods, commas, dashes, colons, and exclamation and question marks. The total length of the message is at most 10000 symbols. Words consist of letters and can be separated by spaces, line breaks, and punctuation marks.
Output
Output “Tram driver” if the user who has posted the latest message is a tram driver; output “Trolleybus driver” if she is a trolleybus driver; and output “Bus driver” if she is a bus driver.
Samples
of course, tram is the best transportin the world!
Tram driver
yes, yekaterinburg trams are thebest trams in the world, buti like my trolleybus too.
Trolleybus driver
read forum.tr.ru every day!you can learn much about tram drivers and trolleybus drivers.
Bus driver
代码如下:
#include <cstdio>#include <cmath>#include <cstring>#include <string>#include <cstring>#include <vector>#include <map>#include <iostream>#include <algorithm>using namespace std;char s[10047];int judge(char c){ if(c >= 'a' && c <= 'z') { return 1; } return 0;}int main(){ char s1[17]; int a = 0, b = 0; while(~scanf("%s",&s)) { memset(s1, '\0',sizeof(s1)); int len = strlen(s); for(int i = 0; i < len; i++) { if(!judge(s[i])) { continue; } int k = 0; while(judge(s[i])) { s1[k++] = s[i]; i++; } if(strcmp(s1, "tram") == 0) { a++; } if(strcmp(s1, "trolleybus") == 0) { b++; } } } //printf("a:%d b:%d\n",a,b); if(a > b) { printf("Tram driver\n"); } else if(a < b) { printf("Trolleybus driver\n"); } else { printf("Bus driver\n"); } return 0;}
1 0
- URAL 1612. Tram Forum(字符串啊 )
- URAL 1585. Penguins (字符串)
- Tram
- Tram
- forum(Bootstrap)
- URAL 1486(二维字符串hash)
- poj 1847(floyd) Tram
- POJ 1847----Tram(Floyd)
- 字符串专项:Ural 1723
- 字符串专项:Ural 1102
- 字符串专项:Ural 1354
- 字符串专项:Ural 1423
- URAL 1989 Subpalindromes(字符串HASH&线段树单点更新)
- URAL 1989 Subpalindromes(线段树单点修改+字符串hash)
- poj 1847 Tram(floyd)
- poj 1847 Tram(最短路径)
- POJ 1847 Tram(floyd 最短路)
- Tram(转换为最短路模型)
- 验证码倒计时发送
- cocos2dx 菜单制作+弹性弹出特效
- vim生成连续数字列
- Android上学习ARM指令集之开篇
- Krypton Factor
- URAL 1612. Tram Forum(字符串啊 )
- Android应用之离线功能的实现思路
- jdk环境变量配置
- centos的rpm和yum
- NYOJ 284 坦克大战 && POJ 2312 Battle City (广搜+优先队列)
- 阿里云 服务器,云盾的ip占用大量流量的问题
- spring之注解(三)Component
- 解决Hadoop namenode无法启动以及修改hdfs的存放位置
- Hadoop2.5.2 Eclipse插件安装及相关问题