题意:
给你一个字符串,串中的hehe可以有两个意思。
可以发现一个he有一个意思,2个he有2个,3个he有3个,4个he有5个,5个有8个,2>3>5>8,很显然出来了
#include"stdio.h"
#include"string.h"
#define N 5100
#define M 10007
int A[N];
void init()
{
A[0]=1;
A[1]=1;
A[2]=2;
A[3]=3;
int i;
for(i=4;i<N;i++)
A[i]=(A[i-1]+A[i-2])%M;
}
int main()
{
int T,t;
int i;
int ans,cnt;
char s[N*2];
init();
t=1;
scanf("%d",&T);
getchar();
while(T--)
{
ans=1;
cnt=0;
gets(s);
for(i=0;s[i];i++)
{
if(s[i]=='h'&&s[i+1]=='e')i++,cnt++;
else if(cnt!=0)
{
ans*=A[cnt];
ans%=M;
cnt=0;
}
}
if(s[i-1]=='e'&&s[i-2]=='h')
{
ans*=A[cnt];
ans%=M;
}
printf("Case %d: %d\n",t++,ans);
}
return 0;
}