Hangzhou Electric 5007Post Robot

Source: Internet
Author: User
Tags printable characters

Post Robot Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 725 Accepted Submission (s): 540


Problem Descriptiondt is a big fan of digital products. He writes posts about technological products almost everyday in his blog.

But there was such few comments of his posts, he feels depressed all the day. As his best friend and a excellent programmer, DT asked you to help make his blog look more popular. He's so warm and that's no idea how to refuse. Unwilling to read all of the 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" is the most high-frequency words on his blog. Once One of these words were read by your smart script, it'll make a comment "Mai Mai mai!", and go on reading the post.

In order to do it more funny, you, as a fan of Sony, also want to make some comments about Sony. Want to add a new rule to the Script:make a comment "Sony Dafa are good!" when "Sony" appears.

Inputa Blog article described above, which contains only printable characters (whose ASCII code is between + and 127), CR ( ASCII code, ' \ r ' in C + +, LF (ASCII code, ' \ n ' in C + +), please process input until EOF. Note all characters is Case Sensitive.

The size of the article does not exceed 8KB.
Outputoutput should contains comments generated by your script, one per line.
Sample Input
Apple Bananaipad Lemon Applepisony233tim Cook is doubi from AppleiPhoneipadiPhone30 are so Biiiiiiig microsoftmakes good Ap P.

Sample Output
Mai Mai mai! Mai Mai mai! Mai Mai mai! SONY Dafa is good! Mai Mai mai! Mai Mai mai! Mai Mai mai!

Source2014 ACM/ICPC Asia Regional Xi ' an Online
Test instructions Analysis: from the string inside to find the word string problem, at that time was thinking of using AC automata, from the Internet a search only to know that the use of brute force solution is relatively simple.
Input:
Apple Bananaipad Lemon Applepisony
233
Tim Cook is doubi from Apple
Iphoneipad
IPhone30 is so Biiiiiiig Microsoft
Makes good App.
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 <stdio.h> #include <string.h> #include <algorithm>using namespace Std;int Main () {    string str;    while (CIN>>STR)    {        int n=str.length ();        for (int i=0;i<n;i++)        {            string a=str.substr (i,4);            if (a== "IPad" | | a== "IPod")            {                printf ("Mai Mai mai!\n");            }            else if (a== "Sony")                printf ("Sony Dafa is good!\n");            String B=str.substr (i,5);            if (b== "Apple")            {                printf ("Mai Mai mai!\n");            }            String C=str.substr (i,6);            if (c== "IPhone")            {                printf ("Mai Mai mai!\n");    }}} return 0;}


Hangzhou Electric 5007Post Robot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.