Good Morning
Time Limit: 1000 ms Memory Limit: 65536 kB Solved: 242 Tried: 2806
Description
Sam loves Lily very much that he shows his love to her through all kinds of ways. This morning, Lily received an e-mail from Sam. Lily knows that Sam hided "good morning" in this mail. Lily tried several ways to resort the letters (including the space ' ') so that more "good morning"s could be found. The number of "good morning" appeared in a specified string equals the number of positions from which Lily could see a consecutive string "good morning".
With so many letters, Lily is about to be dizzy. She asks you to tell her what is the maximum number of "good morning"s appear in this mail after rearranged in some way.Input
Output
Sample Input
2
gninrom doogggoooodd mmoorrnniinnggSample Output
Case #1: 1
Case #2: 2Source
Sichuan State Programming Contest 2011
看题的时候一定要认真地去读题,千万不能略读。
题意:读入一个字符串,重组字符之后,输出字符串中good morning的个数
特殊样例:
请理解下面的case1ggoooodd(空格)(空格)mmoorrnniinng这个case要输出2原因是上面的字母可以重组为good morningood morning这样就出现了两个good morning
code:
1 #include2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int main() 9 {10 int t,i;11 int cas=0;12 string str;13 int num[10];14 cin>>t;15 getline(cin,str);16 while(t--)17 {18 memset(num,0,sizeof(num));19 getline(cin,str);20 for(i=0;i 0) 40 num[0]--;41 num[1]/=3;42 num[4]/=2;43 int count=*min_element(num,num+7);44 cout<<"Case #"<<++cas<<": "< <