HDU 2617 Happy 2009

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;
}

时间: 2024-08-12 04:34:54

HDU 2617 Happy 2009的相关文章

HDU 2617 Happy 2009(字符串)

Happy 2009 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2394    Accepted Submission(s): 802 Problem Description No matter you know me or not. Bless you happy in 2009. Input The input contain

(hdu step 2.2.8)N!Again(求N!的阶乘%2009以后的结果)

题目: N!Again Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 941 Accepted Submission(s): 526   Problem Description WhereIsHeroFrom:             Zty, what are you doing ?Zty:                        

hdu 2009

http://acm.hdu.edu.cn/showproblem.php?pid=2009 #include<iostream> #include<stdio.h> #include<math.h> #include<queue> #include<stack> #include<algorithm> #define PI 3.1415927 using namespace std; int main() { double n,m,

HDU 2009 整除的尾数 题解

Problem Description 一个整数,只知道前几位,不知道末二位,被另一个整数除尽了,那么该数的末二位该是什么呢? Input 输入数据有若干组,每组数据包含二个整数a,b(0<a<10000, 10<b<100),若遇到0 0则处理结束. Output 对应每组数据,将满足条件的所有尾数在一行内输出,格式见样本输出.同组数据的输出,其每个尾数之间空一格,行末没有空格. Sample Input 200 40 1992 95 0 0 Sample Output 00 4

HDU 2009 (水)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2009 题目大意:数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和 解题思路: 用好sqrt() 函数 1 #include<iostream> 2 #include<cmath> 3 #include<iomanip> 4 using namespace std; 5 int main() 6 { 7 double m; 8 int n; 9 while(ci

hdu 2009 求数列和

无聊,刷水题练下java import java.util.*; public class Main { public static void main(String[] args){ Scanner cin=new Scanner(System.in); double n; int m; while(cin.hasNext()) { n=cin.nextDouble(); m=cin.nextInt(); double sum=n; for(int i=0;i<m-1;i++) { sum+=

hdu 2009 求数列的和

求数列的和 思路:利用sqrt函数计算根号,再依次累计相加 代码: #include<iostream> #include<math.h> using namespace std; int main() { double m, n; double num, sum; while (cin >> m >> n) { sum = 0; num = m; int i; for (i = 0; i < n; i++) { sum += num; num = s

HDU 3068 最长回文 (manacher算法)

最长回文 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9188    Accepted Submission(s): 3159 Problem Description 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度. 回文就是正反读都是一样的字符串,如aba, abba等 Input 输入有多组

HDU——T 2818 Building Block

http://acm.hdu.edu.cn/showproblem.php?pid=2818 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5935    Accepted Submission(s): 1838 Problem Description John are playing with blocks. There are N