0%

HDU 4639 Hehe (2013多校第四场H)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* dp[i]的意思是一直到i的时候有多少种可能性
*
* */
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#define MID(x,y) ((x+y)>>1)
#define iabs(x) ((x)>0?(x):-(x))
#define mod 10007
using namespace std;
int main(){
int dp[10100];
char s[10100];
int t,cas=1;
scanf("%d", &t);
while(t--){
scanf("%s", s);
int len = strlen(s);
dp[0] = 1;
for (int i = 1; i < len; ++i){
dp[i] = dp[i-1];
if(i >= 3 && s[i] == 'e' && s[i-1] == &#39;h&#39; &&
s[i-2] == 'e' && s[i-3] == &#39;h&#39;){
dp[i] = (dp[i]+dp[i-3])%mod;
}
}
printf("Case %d: %dn", cas++, dp[len-1]);
}
return 0;
}