HDU 2617 Happy 2009

Source: Internet
Author: User

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

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.