Post Robot

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K

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 ApplepiSony

233

Tim cook is doubi from Apple

iPhoneipad

iPhone30 is so biiiiiiig Microsoft

makes 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!

题解:上手题,使用string标准库函数 find(string str,int i),返回值为从i开始找到str为止的第一个位置,所以使用pos-i==0 判断当前位置是否匹配。find()函数找不到匹配字符串时返回-1。

以下是代码:   

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <cctype>
#include <sstream>
#include <queue>
using namespace std; #define F(i,s,e) for(int i = s;i<e;i++)
#define ss(x) scanf("%d",&x)
#define write() freopen("1.in","r",stdin)
#define W(x) while(x) string str[4]={"iPod","iPad","iPhone","Apple"};
int main(){
//write();
string s;
W(getline(cin,s)){
int len = s.length();
F(i,0,len){
F(j,0,4){
int pos = s.find(str[j],i);
if(pos - i ==0){
cout << "MAI MAI MAI!"<<endl;
break;
}
}
int pos = s.find("Sony",i);
if(pos - i ==0)cout << "SONY DAFA IS GOOD!"<<endl;
}
}
}

  

 

Spring-1-A Post Robot(HDU 5007)解题报告及测试数据的更多相关文章

  1. BestCoder18 1002.Math Problem(hdu 5105) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5105 题目意思:给出一个6个实数:a, b, c, d, l, r.通过在[l, r]中取数 x,使得 ...

  2. BestCoder17 1002.Select(hdu 5101) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5101 题目意思:给出 n 个 classes 和 Dudu 的 IQ(为k),每个classes 都有 ...

  3. BestCoder8 1001.Summary(hdu 4989) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4989 题目意思:给出 n 个数,然后将这些数两两相加,得到 n*(n-1) /2 对和,把重复的和去掉 ...

  4. BestCoder24 1001.Sum Sum Sum(hdu 5150) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5150 题目意思:就是直接求素数. 不过 n = 1,也属于答案范围!!只能说,一失足成千古恨啊---- ...

  5. BestCoder22 1002.NPY and arithmetic progression(hdu 5143) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5143 题目意思:给出 1, 2, 3, 4 的数量,分别为a1, a2, a3, a4,问是否在每个数 ...

  6. BestCoder20 1002.lines (hdu 5124) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5124 题目意思:给出 n 条线段,每条线段用两个整数描述,对于第 i 条线段:xi,yi 表示该条线段 ...

  7. BestCoder19 1001.Alexandra and Prime Numbers(hdu 5108) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5108 题目意思:给出一个数正整数 N,N <= 1e9,现在需要找出一个最少的正整数 M,使得 ...

  8. BestCoder17 1001.Chessboard(hdu 5100) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5100 题目意思:有一个 n * n 的棋盘,需要用 k * 1 的瓷砖去覆盖,问最大覆盖面积是多少. ...

  9. BestCoder16 1002.Revenge of LIS II(hdu 5087) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5087 题目意思:找出第二个最长递增子序列,输出长度.就是说,假如序列为 1 1 2,第二长递增子序列是 ...

随机推荐

  1. jboss6.4 域模式自动部署

    1.通过jenkins传递部署包到服务器,调用自动部署shell完成jboss6.4的域模式部署: 2.自动部署shell如下: 完成部署包重命名(从jenkins过来的包可能没有改名:). 调用jb ...

  2. pythonanywhere笔记

    https://www.pythonanywhere.com Deploying an existing Django project on PythonAnywhere Deploying a Dj ...

  3. cocos lua 加密方案

    cocos2d使用的是luajit,lua原生编译出来的bytecode和luajit是不兼容的,所以直接用luac法编译出来的bytecode脚本无法在cocos2d中使用. 目前所指的解决方案有2 ...

  4. Zabbix自动发现与主动注册

    接上篇:Zabbix监控主动模式 网络自动发现 zabbix agent的配置文件/etc/zabbix/zabbix_agentd.conf 注释StartAgents=0 添加 HostnameI ...

  5. ionic 上拉加载问题(分页)

    问题描述: 1.第一初始化时执行了上拉加载更多. 2.上拉时存在执行多次加载动作. angularjs的ajax不提供同步机制,是为了防止页面长时间等待,很多时候我们又需要这种同步机制交换状态,比如上 ...

  6. Code Forces 22B Bargaining Table

    B. Bargaining Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Powershell替代和截断——replace and substring

    一:截取一个字符串的尾部,替代字符串中的特定字符或替代字符串中特定位置的特定字符 $a="W.endy.chen.SHAO" $b=$a.Substring(0,$a.Length ...

  8. jquery的强大选择器

    $("#myELement")    选择id值等于myElement的元素,id值不能重复在文档中只能有一个id值是myElement所以得到的是唯一的元素 $("di ...

  9. 随笔 javascript-抽象工厂模式

    随笔   javascript-抽象工厂模式 抽象工厂模式笔记   1.抽象工厂模式创建多个抽象类,创建出的结果是一个类簇(这里是抽象类的集合)   2.抽象工厂中传入的父类是否是抽象工厂方法创建的抽 ...

  10. Clairewd’s message--hdu4300(Next数组的运用)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4300 题意就是给你26的字母的加密方式,然后又给了一个串s1是包含加密后的和没有加密的但是没有加密的可 ...