# HDU4639:Hehe

Problem Description
As we all know, Fat Brother likes MeiZi every much, he always find some topic to talk with her. But as Fat Brother is so low profile that no one knows he is a rich-two-generation expect the author, MeiZi always rejects him by typing “hehe” (wqnmlgb). You have to believe that there is still some idealized person just like Fat Brother. They think that the meaning of “hehe” is just “hehe”, such like “hihi”, “haha” and so on. But indeed sometimes “hehe” may really means “hehe”. Now you are given a sentence, every “hehe” in this sentence can replace by “wqnmlgb” or just “hehe”, please calculate that how many different meaning of this sentence may be. Note that “wqnmlgb” means “我去年买了个表” in Chinese.

Input
The first line contains only one integer T, which is the number of test cases.Each test case contains a string means the given sentence. Note that the given sentence just consists of lowercase letters.
T<=100
The length of each sentence <= 10086

Output
For each test case, output the case number first, and then output the number of the different meaning of this sentence may be. Since this number may be quite large, you should output the answer modulo 10007.

Sample Input

4
wanshangniyoukongme
womenyiqichuqukanxingxingba
bulehehewohaiyoushi
eheheheh


Sample Output

Case 1: 1
Case 2: 1
Case 3: 2
Case 4: 3


#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define LS 2*i
#define RS 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 10090
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 10007;

int f[N],len,t,cas=1;
char str[N];

int main()
{
int i,j,k,ans;
f[0] = 1;
f[1] = 1;
for(i = 2;i<N;i++)
{
f[i] = (f[i-1]+f[i-2])%mod;
}
scanf("%d",&t);
while(t--)
{
ans = 0;
int cnt = 0;
scanf("%s",str);
len = strlen(str);
str[len++] = '#';
str[len] = '\0';
for(i = 1;i<=len;i++)
{
if(str[i]=='e'&&str[i-1]=='h')
{
cnt++;
i++;
}
else
{
if(ans==0)
{
ans = f[cnt];
}
else
{
ans = (ans*f[cnt])%mod;
}
cnt = 0;
}
}
printf("Case %d: %d\n",cas++,ans);
}

return 0;
}


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

键盘上的舞者

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文
10-26
08-01 1616

08-01 578
08-15 545
09-18 334
08-03 417
01-10 510
08-03 1394
11-04 455
10-20