hdu 5007 水题 (2014西安网赛A题)
题意:出现Apple、iPod、iPhone、iPad时输出MAI MAI MAI!,出现Sony,输出SONY DAFA IS GOOD!
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!
1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <string> 5 # include <algorithm> 6 # include <cmath> 7 # include <queue> 8 # define LL long long 9 using namespace std ; 10 11 12 int main () 13 { 14 //freopen("in.txt","r",stdin) ; 15 string s ; 16 while(cin>>s) 17 { 18 int len = s.size() ; 19 int i ; 20 for (i = 0 ; i < len ; i++) 21 { 22 string a = s.substr(i,4) ; 23 if (a == "iPad" ||a == "iPod") 24 cout<<"MAI MAI MAI!"<<endl ; 25 else if (a == "Sony") 26 cout<<"SONY DAFA IS GOOD!"<<endl ; 27 string b = s.substr(i, 5); 28 if (b == "Apple") 29 cout<<"MAI MAI MAI!"<<endl ; 30 string c = s.substr(i, 6); 31 if (c == "iPhone") 32 cout<<"MAI MAI MAI!"<<endl ; 33 34 } 35 } 36 37 return 0 ; 38 }