hdu 4639

/*一个he都没有和有一个he结果是1
2个he  是2
3个he    3
4个he    5
5个he    8
。。。。。
把每段的结果相乘取余*/
#include<stdio.h>
#include<string.h>
#define N 10007
int f[11000];
int main() {
int t,i,j,k,n,m,sum,count=0,len,ans;
char s[11000];
f[0]=f[1]=1;
for(i=2;i<=10100;i++)
f[i]=(f[i-1]+f[i-2])%N;
scanf("%d",&t);
while(t--) {
scanf("%s",s);
len=strlen(s);
sum=0;ans=1;
for(i=1;i<len;i++) {
if(s[i]=='e'&&s[i-1]=='h') {
i++;sum++;
}
else {
ans=ans*f[sum]%N;
sum=0;
}
}
ans=ans*f[sum]%N;
printf("Case %d: %d ",++count,ans);
}
return 0;
}
原文地址:https://www.cnblogs.com/thefirstfeeling/p/4410944.html