Happy 2009

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2750    Accepted Submission(s): 919

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
 
Author
yifenfei
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define MAX 11000
using namespace std;
int main()
{
int n,m,j,i;
char s[MAX];
while(gets(s))
{
int len=strlen(s);
int h,a,p,y;
h=a=p=y=0;
for(i=0;i<len;i++)
{
if(s[i]=='h')
h++;
if(s[i]=='a')
{
if(a<h)
a++;
}
if(s[i]=='p')
{
if(p<2*a)
p++;
}
if(s[i]=='y')
{
if(y<p/2)
y++;
}
}
printf("%d\n",y);
}
return 0;
}

  

最新文章

  1. screen
  2. asp.net 手工调用 WS(Get)方法:
  3. Web Service中的几个重要术语
  4. shell之eval-command
  5. js判断汉字字数
  6. 12.iscsi-target
  7. Go在linux下的安装
  8. hibernate关联关系映射详解
  9. 一个urllib2构建的html下载器的代理组件的实现方案
  10. OR扩展
  11. 成功为Android系统配上了GNU开发环境
  12. 《吸血鬼日记》(The Vampire Diaries)经典台词
  13. 用SpringBoot搭建简单电商项目 01
  14. 多线程(四) 实现线程范围内模块之间共享数据及线程间数据独立(Map集合)
  15. ExtJS学习(四)EditorGrid可编辑表格
  16. window安装mysql5.7解压版(解决乱码问题)
  17. php框架rbac功能分析
  18. saltstack二
  19. springmvc异步上传图片并回调页面函数插入图片url代码示例
  20. FreeChart柱状图中如何取消柱子的倒影

热门文章

  1. MySql不同版本安装
  2. 221. Maximal Square
  3. Oracle 学习笔记 常用查询命令篇
  4. autocapticalize和autocorrect
  5. (从终端看linux-2)浅析terminal创建时ptmx和pts关系
  6. 8款替代Dreamweaver的开源网页开发工具
  7. NPOI的测试代码
  8. node安装插件方法
  9. ↗☻【HTML5秘籍 #BOOK#】第2章 构造网页的新方式
  10. Xcode8安装不成功, 需要升级系统. The operation couldn&#39;t be completed. cpio read error