hdu 4639 Hehe

这个我只能说出题人太和谐了,不仅“hehe”,还拿斐波那契额数列逗我们。。。

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 int f[5050];
 5 char str[10100];
 6 
 7 int main()
 8 {
 9     int T;
10     scanf("%d",&T);
11     f[0]=f[1]=1;
12     for(int i=2;i<5050;i++)
13         f[i]=(f[i-1]+f[i-2])%10007;
14     for(int k=1;k<=T;k++)
15     {
16         scanf("%s",str);
17         int len=strlen(str);
18         int s=1;
19         for(int i=0;i<len;i++)
20         {
21             if(str[i]=='h'&&str[i+1]=='e'){
22                 i+=2;
23                 int ans=1;
24                 while(i<len-1&&str[i]=='h'&&str[i+1]=='e')
25                 {
26                     i+=2;
27                     ans++;
28                 }
29                 s=s*f[ans]%10007;
30             }
31         }
32         printf("Case %d: %d
",k,s);
33     }
34     return 0;
35 }
View Code
原文地址:https://www.cnblogs.com/zstu-abc/p/3233753.html