hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
来源:互联网 发布:js获取style 编辑:程序博客网 时间:2024/05/01 12:24
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5007
Problem Description
DT is a big fan of digital products. He writes posts about technological products almost everyday in his blog.
But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.
After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will make a comment “MAI MAI MAI!”, and go on reading the post.
In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.
But there is such few comments of his posts that he feels depressed all the day. As his best friend and an excellent programmer, DT asked you to help make his blog look more popular. He is so warm that you have no idea how to refuse. But you are unwilling to read all of his boring posts word by word. So you decided to write a script to comment below his posts automatically.
After observation, you found words “Apple” appear everywhere in his posts. After your counting, you concluded that “Apple”, “iPhone”, “iPod”, “iPad” are the most high-frequency words in his blog. Once one of these words were read by your smart script, it will make a comment “MAI MAI MAI!”, and go on reading the post.
In order to make it more funny, you, as a fan of Sony, also want to make some comments about Sony. So you want to add a new rule to the script: make a comment “SONY DAFA IS GOOD!” when “Sony” appears.
Input
A blog article described above, which contains only printable characters(whose ASCII code is between 32 and 127), CR(ASCII code 13, ‘\r’ in C/C++), LF(ASCII code 10, ‘\n’ in C/C++), please process input until EOF. Note all characters are case sensitive.
The size of the article does not exceed 8KB.
The size of the article does not exceed 8KB.
Output
Output should contains comments generated by your script, one per line.
Sample Input
Apple bananaiPad lemon ApplepiSony233Tim cook is doubi from AppleiPhoneipadiPhone30 is so biiiiiiig Microsoftmakes good App.
Sample Output
MAI MAI MAI!MAI MAI MAI!MAI MAI MAI!SONY DAFA IS GOOD!MAI MAI MAI!MAI MAI MAI!MAI MAI MAI!
Source
2014 ACM/ICPC Asia Regional Xi'an Online
下面的代码有问题,不过数据太水了,所以A了....
#include <algorithm>#include <cstdlib>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <cctype>#include <cmath>#include <stack>#include <queue>#include <list>#include <map>#include <set>using namespace std;#define min2(x, y) min(x, y)#define max2(x, y) max(x, y)#define min3(x, y, z) min(x, min(y, z))#define max3(x, y, z) max3(x, max(y, z))#define clr(x, y) memset(x, y, sizeof(x))#define fr(i,n) for(int i = 0; i < n; i++)#define fr1(i,n) for(int i = 1; i < n; i++)#define upfr(i,j,n) for(int i = j; i <= n; i++)#define dowfr(i,j,n) for(int i = n; i >= j; i--)#define scf(n) scanf("%d", &n)#define ptf(n) printf("%d",n)#define ptfs(s) printf("%s",s)#define ptln() printf("\n")#define srt(a,n) sort(a,n)#define LL long long#define pi acos(-1.0)#define inf 1 << 31-1#define eps 0.00001#define maxn 100005int main(){ string s; while(cin >> s) { if(s.find("Apple",0)!=-1 || s.find("iPhone",0)!=-1 ||s.find("iPod",0)!=-1 ||s.find("iPad",0)!=-1 ) cout << "MAI MAI MAI!" <<endl; if(s.find("Sony",0)!= -1) cout << "SONY DAFA IS GOOD!" << endl; } return 0;}
正确姿势:
#include <algorithm>#include <cstdlib>#include <iostream>#include <cstring>#include <cstdio>#include <vector>#include <cctype>#include <cmath>#include <stack>#include <queue>#include <list>#include <map>#include <set>using namespace std;#define min2(x, y) min(x, y)#define max2(x, y) max(x, y)#define min3(x, y, z) min(x, min(y, z))#define max3(x, y, z) max3(x, max(y, z))#define clr(x, y) memset(x, y, sizeof(x))#define fr(i,n) for(int i = 0; i < n; i++)#define fr1(i,n) for(int i = 1; i < n; i++)#define upfr(i,j,n) for(int i = j; i <= n; i++)#define dowfr(i,j,n) for(int i = n; i >= j; i--)#define scf(n) scanf("%d", &n)#define ptf(n) printf("%d",n)#define ptfs(s) printf("%s",s)#define ptln() printf("\n")#define srt(a,n) sort(a,n)#define LL long long#define pi acos(-1.0)#define inf 1 << 31-1#define eps 0.00001#define maxn 100005int main(){ //freopen("in.txt", "r", stdin); string s; while(cin >> s) { int len = s.length(); fr(i, len) { string ss = ""; ss += s[i]; if(i + 1 < len) ss += s[i + 1]; if(i + 2 < len) ss += s[i + 2]; if(i + 3 < len) ss += s[i + 3]; if(ss == "iPad" || ss == "iPod") cout << "MAI MAI MAI!"<< endl; else if(ss == "Sony") cout << "SONY DAFA IS GOOD!" <<endl; else { if(i + 4 < len) ss += s[i + 4]; if(ss == "Apple") cout << "MAI MAI MAI!"<< endl; else { if(i + 5 < len) ss += s[i + 5]; if(ss == "iPhone") cout << "MAI MAI MAI!"<< endl; } } } } return 0;}
0 0
- hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
- 2014 ACM/ICPC Asia Regional Xi'an Online poj5007 Post Robot
- 2014 ACM/ICPC Asia Regional Xi'an Online(hdu 5007 - hdu 5017)
- 2014 ACM/ICPC Asia Regional Xi'an Online 小记
- 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5015 233 Matrix 2014 ACM/ICPC Asia Regional Xi'an Online 矩阵快速幂
- hdu 5012 Dice 2014 ACM/ICPC Asia Regional Xi'an Online bfs
- hdu 5014 Number Sequence 2014 ACM/ICPC Asia Regional Xi'an Online 数论
- HDU 5014 Number Sequence 贪心 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 1009 233 Matrix 矩阵构造 --2014 ACM/ICPC Asia Regional Xi'an Online
- HDU 5015 233 Matrix / 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5014 Number Sequence 找规律 | 贪心 2014 ACM/ICPC Asia Regional Xi'an Online
- hdu 5008(2014 ACM/ICPC Asia Regional Xi'an Online ) Boring String Problem(后缀数组&二分)
- hdu 5011 Game Nim博弈 2014 ACM/ICPC Asia Regional Xi'an Online
- 2014 ACM/ICPC Asia Regional Xi'an Online 233 Matrix,hdu 5015
- hdu 5012 Dice BFS 2014 ACM/ICPC Asia Regional Xi'an Online
- HDU5014(异或) HDU 5012(BFS)(2014 ACM/ICPC Asia Regional Xi'an Online)题解
- hdu 5009 Paint Pearls 2014 ACM/ICPC Asia Regional Xi'an Online
- Exception in thread "main" java.lang.ClassCastException: java.math.BigDecimal cannot be cast to ja
- 安装配置 CentOS6.5 minimal 遇到的问题
- Oracle锁的机制。
- linux zip/unzip命令详解
- 虚拟机堆OutOfMemoryError异常
- hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
- 字符串匹配
- mongodb 副本集创建(一)
- 记录华为中央研究院的面试20140913
- 高效时间管理-介绍GTD
- SAE平台下搭建个人博客WORDPRESS
- 配置win2008防火墙 允许被Ping的设置方法
- Dinic非递归版(优化)
- 简单工厂、工厂方法、抽象工厂之小结与区别