hdu 5007 Post Robot 水题

来源:互联网 发布:php 反射获取类变量 编辑:程序博客网 时间:2024/05/21 18:47

Post Robot

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


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.
 

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.
 

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!
 
为了防止上次多校字符串太长,一个一个读。
#include<iostream>#include<cstdio>#include<cstdlib>#include<ctime>#include<string>#include<cstring>#include<algorithm>#include<queue>#include<stack>#include<vector>#include<cmath>#define MM(a,t) memset(a,t,sizeof(a))#define rep(i,n) for(i=1;i<=n;i++)#define INF 1e9typedef long long ll;#define mod 1000000007using namespace std;char st1[100]="Apple",st2[100]="iPhone",st3[100]="iPod",st4[100]="iPad",st5[100]="Sony";int l1,l2,l3,l4,l5;int main(){        int i,j;    char c;        while((c=getchar())!=EOF){      if(c==st1[l1]){          l1++;        if(l1==5){          printf("MAI MAI MAI!\n");          l1=0;            }            }      else l1=0;      if(c==st2[l2]){          l2++;        if(l2==6){          printf("MAI MAI MAI!\n");          l2=0;            }            }      else l2=0;      if(c==st3[l3]){          l3++;        if(l3==4){          printf("MAI MAI MAI!\n");          l3=0;            }            }      else l3=0;      if(c==st4[l4]){          l4++;        if(l4==4){          printf("MAI MAI MAI!\n");          l4=0;            }            }      else l4=0;      if(c==st5[l5]){          l5++;        if(l5==4){          printf("SONY DAFA IS GOOD!\n");          l5=0;            }            }      else l5=0;        }            return 0;}



0 0
原创粉丝点击