hdu 5007 Post Robot
来源:互联网 发布:过道建筑面积算法 编辑:程序博客网 时间:2024/06/06 15:48
Post Robot
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 253 Accepted Submission(s): 207
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
题解及代码:
简单粗暴的暴力。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#include <vector>#include <map>using namespace std;int main(){ char s[10010],t[10010]; memset(s,0,sizeof(s)); while(scanf("%s",t)!=EOF) { strcat(s,t); } int len=strlen(s); for(int i=0;i<len;i++) { if(i+3<len) { if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='o'&&s[i+3]=='d') printf("MAI MAI MAI!\n"); if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='a'&&s[i+3]=='d') printf("MAI MAI MAI!\n"); if(s[i]=='S'&&s[i+1]=='o'&&s[i+2]=='n'&&s[i+3]=='y') printf("SONY DAFA IS GOOD!\n"); } if(i+4<len) { if(s[i]=='A'&&s[i+1]=='p'&&s[i+2]=='p'&&s[i+3]=='l'&&s[i+4]=='e') printf("MAI MAI MAI!\n"); } if(i+5<len) { if(s[i]=='i'&&s[i+1]=='P'&&s[i+2]=='h'&&s[i+3]=='o'&&s[i+4]=='n'&&s[i+5]=='e') printf("MAI MAI MAI!\n"); } } return 0;}
0 0
- HDU - 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot
- hdu 5007 Post Robot 水题
- hdu 5007 Post Robot(水题)
- HDU 5007 Post Robot(字符串寻找)
- HDU-#5007 Post Robot(暴力)
- HDU 5007-Post Robot(字符串)
- HDU——5007 Post Robot
- 字符串水题 hdu 5007 Post Robot
- hdu 5007 Post Robot【模拟】水题
- HDU 5007 Post Robot(西安网络赛A题)
- HDOJ 5007 Post Robot
- 杭电5007Post Robot
- Post Robot
- hdu 5007 Post Robot 水题 2014 ACM/ICPC Asia Regional Xi'an Online
- fcitx输入法安装很简单的方法
- 魔术球问题 二分图的最小路径覆盖+输出解
- application/x-www-form-urlencoded等字符编码的解释说明
- 《数据结构》第一章绪论知识总结导图
- jquery操作复选框(checkbox)的12个小技巧总结
- hdu 5007 Post Robot
- HDU 1090 A+B for Input-Output Practice (II)
- HDU 5012 Dice
- Android里的底部页面的切换的实现的三种方式
- 程序员如何快速准备面试中的算法
- Function Run Fu
- hdu 5011 Game
- OC之继承,初始化方法,便利构造器
- 一张图让你看清Java集合类(Java集合类的总结)