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
|
#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] == 'h' && s[i-2] == 'e' && s[i-3] == 'h'){ dp[i] = (dp[i]+dp[i-3])%mod; } } printf("Case %d: %dn", cas++, dp[len-1]); } return 0; }
|