博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4639 Hehe
阅读量:6070 次
发布时间:2019-06-20

本文共 2784 字,大约阅读时间需要 9 分钟。

Hehe

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 355    Accepted Submission(s): 202

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
 

 

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
4 wanshangniyoukongme womenyiqichuqukanxingxingba bulehehewohaiyoushi eheheheh
 

 

Sample Output
Case 1: 1 Case 2: 1 Case 3: 2 Case 4: 3
 

 

Source
 

 

Recommend
zhuyuanchen520
 

 我用的是组合的方法:

#include
#include
#include
#include
using namespace std;const int mod=10007;char str[12000];int C[1000][1000];void init(){ for(int i=0;i<1000;i++){ C[i][i]=C[i][0]=1; for(int j=1;j
=2){ for(int i=1;i<=cnt/2;i++){ tmp=(tmp+C[i+cnt-i*2][i])%mod; } } ans=(ans*tmp)%mod; } printf("Case %d: %d\n",++cases,ans); } return 0;}

 

另一种思路:

思路: 斐波那契数列

#include 
#include
#include
#include
#include
#include
using namespace std; //斐波那契数列 const int V = 5050 + 50; const int MaxN = 500 + 5; const int mod = 10000 + 7; int T, ans, num[V]; char ch[10100]; int main() { int i, j, k; scanf("%d", &T); num[0] = num[1] = 1; for(i = 2; i <= V; ++i) num[i] = (num[i - 1] + num[i - 2]) % mod; for(i = 1; i <= T; ++i) { ans = 1; int sum = 0; scanf("%s", &ch); int len = strlen(ch); for(j = 1; j < len; ++j) { if(ch[j] == 'e' && ch[j - 1] == 'h') { sum++; j++; } else { ans = (ans * num[sum]) % mod; sum = 0; } } ans = (ans * num[sum]) % mod; printf("Case %d: %d\n", i, ans); } }

 

转载地址:http://vgygx.baihongyu.com/

你可能感兴趣的文章
KVM网络桥接设置方法
查看>>
Puppet学习手册:Puppet Yum安装
查看>>
我的友情链接
查看>>
ansible学习记录
查看>>
网思科技校园网计费解决方案
查看>>
我的友情链接
查看>>
携程 Apollo分布式部署
查看>>
2017 Hackatari Codeathon B. 2Trees(深搜)(想法)
查看>>
单词统计
查看>>
输入一个数字计算圆的面积
查看>>
在Delphi中隐藏程序进程
查看>>
AngularJS PhoneCat代码分析
查看>>
MEF元数据应用说明
查看>>
maven错误解决:编码GBK的不可映射字符
查看>>
2016/4/19 反射
查看>>
SharePoint Wiki发布页面的“保存冲突”
查看>>
oracle 10g 数据库与客户端冲突导致实例创建无监听问题
查看>>
Delphi中读取文本文件的方法(实例一)
查看>>
Linux常用命令
查看>>
Android开源代码解读の使用TelephonyManager获取移动网络信息
查看>>