1 条题解
-
0
C++ :
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> #include<iostream> using namespace std; const int maxn=10100+10; const int mod=10007; int f[maxn]; char s[maxn]; void init() { f[1]=f[0]=1; for(int i=2;i<maxn;i++) f[i]=(f[i-1]+f[i-2])%mod; } int main() { int T,i,c=0; init(); scanf("%d",&T); while(T--) { scanf("%s",s); int len=strlen(s); int ans=1,t=0; for(i=0;i<len;i++) { if(s[i]=='h'&&s[i+1]=='e') { t=1; i+=2; while(s[i]=='h'&&s[i+1]=='e'&&(i+1)<len) { t++; i+=2; } ans=(ans*f[t])%mod; } } printf("Case %d: %d\n",++c,ans); } return 0; }
- 1
信息
- ID
- 1132
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者