HDU4639:Hehe
来源:互联网 发布:佐菲奥特曼act通贬淘宝 编辑:程序博客网 时间:2024/06/07 00:08
Problem Description
As we all know, Fat Brother likes MeiZi every much, he always find some topic to talk with her. But as Fat Brother is so low profile that no one knows he is a rich-two-generation expect the author, MeiZi always rejects him by typing “hehe” (wqnmlgb). You have to believe that there is still some idealized person just like Fat Brother. They think that the meaning of “hehe” is just “hehe”, such like “hihi”, “haha” and so on. But indeed sometimes “hehe” may really means “hehe”. Now you are given a sentence, every “hehe” in this sentence can replace by “wqnmlgb” or just “hehe”, please calculate that how many different meaning of this sentence may be. Note that “wqnmlgb” means “我去年买了个表” in Chinese.
Input
The first line contains only one integer T, which is the number of test cases.Each test case contains a string means the given sentence. Note that the given sentence just consists of lowercase letters.
T<=100
The length of each sentence <= 10086
T<=100
The length of each sentence <= 10086
Output
For each test case, output the case number first, and then output the number of the different meaning of this sentence may be. Since this number may be quite large, you should output the answer modulo 10007.
Sample Input
4wanshangniyoukongmewomenyiqichuqukanxingxingbabulehehewohaiyoushieheheheh
Sample Output
Case 1: 1Case 2: 1Case 3: 2Case 4: 3
题意:每个hehe都表示两个意思,给出一个字符串,问能表示几种意思
思路:可以看出,连续的几个he,表达的意思总数符合斐波那契数列
#include <iostream>#include <stdio.h>#include <string.h>#include <stack>#include <queue>#include <map>#include <set>#include <vector>#include <math.h>#include <bitset>#include <algorithm>#include <climits>using namespace std;#define LS 2*i#define RS 2*i+1#define UP(i,x,y) for(i=x;i<=y;i++)#define DOWN(i,x,y) for(i=x;i>=y;i--)#define MEM(a,x) memset(a,x,sizeof(a))#define W(a) while(a)#define gcd(a,b) __gcd(a,b)#define LL long long#define N 10090#define MOD 1000000007#define INF 0x3f3f3f3f#define EXP 1e-8#define rank rank1const int mod = 10007;int f[N],len,t,cas=1;char str[N];int main(){ int i,j,k,ans; f[0] = 1; f[1] = 1; for(i = 2;i<N;i++) { f[i] = (f[i-1]+f[i-2])%mod; } scanf("%d",&t); while(t--) { ans = 0; int cnt = 0; scanf("%s",str); len = strlen(str); str[len++] = '#'; str[len] = '\0'; for(i = 1;i<=len;i++) { if(str[i]=='e'&&str[i-1]=='h') { cnt++; i++; } else { if(ans==0) { ans = f[cnt]; } else { ans = (ans*f[cnt])%mod; } cnt = 0; } } printf("Case %d: %d\n",cas++,ans); } return 0;}
0 0
- hdu4639 Hehe
- HDU4639:Hehe
- Hehe(hdu4639,斐波拉契数+排列组合)
- HDU4639
- HDU4639
- HEHE
- hehe
- hehe
- HEHE
- hehe
- hehe
- hehe
- hehe
- hehe
- hehe
- hehe
- hehe
- hehe
- JVM工作原理(简单版)
- C++ 返回值为引用
- Linux下安装php扩展
- R的启动顺序及执行文件
- C++用opengl直接调用box2D 的debug绘图
- HDU4639:Hehe
- Ubuntu14.04安装Android编译环境
- 三国杀标准包小程序
- u-apsd
- PowerMock测试小例
- jsoup 简介
- ACM--Crossing River
- 从user 登陆开始
- 这是我看过最好的对hibernate的二级缓存解析