首页 > 移动平台 > 详细

HDU 2617 Happy 2009

时间:2015-11-28 23:04:46      阅读:397      评论:0      收藏:0      [点我收藏+]

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 Description
No matter you know me or not. Bless you happy in 2009.
 

 

Input
The input contains multiple test cases.
Each test case included one string. There are made up of ‘a’-‘z’ or blank. The length of string will not large than 10000. 
 

 

Output
For each test case tell me how many times “happy” can be constructed by using the string. Forbid to change the position of the characters in the string. The answer will small than 1000.
 

 

Sample Input
hopppayppy happy happ acm y hahappyppy
 

 

Sample Output
2 1 2
 
 
 
 
 
 
 
 
 
 
 
 
 
 

#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<h)
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

原文:http://www.cnblogs.com/-lgh/p/5003473.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!