Happy 2009
Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 2757 Accepted Submission (s): 922
Problem Descriptionno matter you know me or not. Bless Happy in 2009.
Inputthe input contains multiple test cases.
Each test case included one string. There is made up of ' a '-' Z ' or blank. The length of string would not be large than 10000.
Outputfor Each test case tell me how many times "happy" can be constructed by using the string. Forbid to the position of the characters in the string. The answer would small than 1000.
Sample inputhopppayppy happyhapp ACM yhahappyppy
Sample Output212
#include <string.h>
#include <stdio.h>
int main ()
{
Char ch[10010];
while (gets (CH))
{
int I,len=strlen (CH), h=0,a=0,p=0,y=0;
for (i=0; i<len; i++)
{
if (ch[i]== ' h ')
h++;
if (ch[i]== ' a ' &&a
a++;
if (ch[i]== ' P ' &&p/2<a)
p++;
else if (ch[i]== ' y ' &&y<p/2)
y++;
}
printf ("%d\n", y);
}
return 0;
}
HDU 2617 Happy 2009