hdu-2617
来源:互联网 发布:元数据ios 编辑:程序博客网 时间:2024/05/17 02:45
Happy 2009
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2439 Accepted Submission(s): 819
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.
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 happyhapp acm yhahappyppy
Sample Output
212此题我竟然没做出来,想想我都想哭,我水平怎么这么水。。。。#include<stdio.h>#include<string.h>int main(){ char string[10012]; int k,i,j; //getchar(); while(gets(string)!=NULL) { int a,b,c1,c2,d; a=0;b=0;c1=0;c2=0;d=0; k=strlen(string); for(i=0;i<k;i++) { if(string[i]=='h') a++; else if(string[i]=='a'&&a>0) { a--; b++; } else if(string[i]=='p') { if(c1>0) { c1--; c2++; } else if(b>0) { b--; c1++; } } else if(string[i]=='y'&&c2>0) { c2--; d++; } } printf("%d\n",d); }return 0;} 用的别人的思路。。。 比较好理解
0 0
- hdu 2617
- hdu-2617
- hdu 2617 Happy 2009
- hdu 2617(水)
- hdu 2617 Happy 2009
- HDU 2617 Happy 2009
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- LayoutInflater作用及使用
- hdu 1466 计算直线的交点数 (简单的动态规划)
- 【ArcGis】ArcObjects SDK(AE)10.1在vs2012安装的方法
- centOS下,源码安装erlang
- JDK自带VM分析工具jps,jstat,jmap,jconsole
- hdu-2617
- NOJ1113斐波那契数应用——分解含有贪心
- 【tyvj1473】校门外的树3
- 找零问题
- C++基础之this指针的详解
- 黑马程序员 【】java学习之路——线程
- 【计算几何】【计算几何模板】【持续更新】
- poj-3070-Fibonacci
- poj 2186(强连通分量的kosaraju算法)