HDUOJ 4639 2013多校第四场第8题 Hehe
来源:互联网 发布:买家注册淘宝客 编辑:程序博客网 时间:2024/05/21 07:05
传送门
题意:给你一串字符,其中hehe可以有另一种意思,问你这串可以有多少意思。
思路:首先想到的就是找hehe,因为其中hehe可以连续,如hehehe,hehehehe,等等,所以要找出规律,这么多连续hehe可以有多少意思,然后发现连续的hehe的意思刚好是斐波那契数列,然后将每段连续hehe的意思数都乘起来就是答案了。
#include<iostream>#include<cstdio>#include<cstring>using namespace std;char a[11111];bool v[11111];int s[11111];int f[11111];int num,ans;int main(){ int t; int c=1; f[0]=1; f[1]=2; for(int i=2;i<=5050;i++) { f[i]=(f[i-1]+f[i-2])%10007; } scanf("%d",&t); while(t--) { memset(s,0,sizeof(s)); memset(v,0,sizeof(v)); scanf("%s",&a); int l=strlen(a); num=0; for(int i=0;i<l-3;i++) { if(a[i]=='h'&&a[i+1]=='e'&&a[i+2]=='h'&&a[i+3]=='e') { if(v[i]==1) { s[num]++; } else s[++num]=1; v[i+2]=1; } } ans=1; for(int i=1;i<=num;i++)ans=(ans*f[s[i]])%10007; cout<<"Case "<<c++<<": "; cout<<ans<<endl; } return 0;}
- HDUOJ 4639 2013多校第四场第8题 Hehe
- HDUOJ 4632 2013多校第四场第1题
- hdu 4639 Hehe 多校第四场
- HDUOJ 4642 2013多校第四场第11题 Fliping game
- HDUOJ 4638 2013多校第四场第7题 Group
- hdu 4639 hehe 多校联合训练第四场
- hdu 4639 2013多校第四场 hehe Fibonacci 数列,组合计数,字符串处理
- HDUOJ 4649 2013多校第五场第7题
- HDUOJ 4647 2013多校第五场第5题
- HDUOJ 4628 2013多校第三场第8题 Pieces
- 2013暑期多校联合训练\第四场\Problem H Hehe
- HDUOJ 4681 2013多校第8场第6题 String
- HDUOJ 4619 (2013多校第二场第9题)
- HDUOJ 4630 2013多校第三场第10题 No Pain No Game
- HDUOJ 4705 2013多校第十场第10题 Y
- 2013 多校第四场
- 多校第四场
- 多校第四场
- 分布式EventBus的Socket实现
- HDU--1610 -- Count the Colors [线段树是也]
- Android开发性能优化简介(转载)
- android 弹出菜单、书架、信息填写界面等
- replace string
- HDUOJ 4639 2013多校第四场第8题 Hehe
- Activity 的onStop以及onDestroy
- 【Python排序搜索基本算法】之二叉树的遍历
- 开通CSDN博客,庆祝一下!
- UVA401 -Palindromes
- 没有梦想
- struts2的Preface
- iOS: imageIO完成渐进加载图片
- 同一个solution下调用程序直接调用另一个Project生成的DLL