Hehe

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 33    Accepted Submission(s): 22

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
 

很水

 /*
* Author:kuangbin
* 1008.cpp
*/ #include <stdio.h>
#include <algorithm>
#include <string.h>
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <math.h>
using namespace std;
const int MOD = ;
int dp[];
void init()
{
dp[] = ;
dp[] = ;
dp[] = ;
for(int i = ;i < ;i++)
dp[i] = (dp[i-] + dp[i-])%MOD;
} char str[]; int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int T;
scanf("%d",&T);
int iCase = ;
init();
while(T--)
{
iCase ++;
scanf("%s",str);
int ans = ;
int len = strlen(str);
for(int i = ; i < len;i++)
{
if(str[i] == 'h')
{
int cnt = ;
for(int j = i ; j+ <len;j+=)
{
if(str[j]!='h'||str[j+]!='e')break;
cnt++;
}
ans = ans*dp[cnt]%MOD;
if(cnt > )
{
i += cnt*;
i--;
}
}
}
printf("Case %d: %d\n",iCase,ans);
}
return ;
}

HDU 4639 Hehe (2013多校4 1008 水题)的更多相关文章

  1. HDU 4662 MU Puzzle (2013多校6 1008 水题)

    MU Puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  2. HDU 4639 Hehe 2013 Multi-University Training Contest 4

    题意大致如下:屌丝找女神聊天,女神回了一句 hehe ,而我们都知道 Hehe 有两个意思,一个就是 Hehe ,另外一个则是 wqnmlgb (我去年买了个表) ,所以屌丝很纠结,于是开始思考到底女 ...

  3. HDU 5832 A water problem (带坑水题)

    A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

  4. HDU 5889 Barricade(最短路+最小割水题)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  5. HDU 4639 hehe 杭电2013多校联赛第四场1008题

    解题报告:题目的意思是输入一个字符串,并规定,里面的“hehe”可以用"wqnmlgb"来代替,也可以不代替,问输入的这个字符串在经过相关的代替之后可以有多少种不同的形态.先打一个 ...

  6. HDU 4618 Palindrome Sub-Array (2013多校2 1008 暴力)

    Palindrome Sub-Array Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Oth ...

  7. hdu 4639 Hehe

    http://acm.hdu.edu.cn/showproblem.php?pid=4639 每一段 "hehe..... " 相互独立  将每一段 "hehe..... ...

  8. 【斐波那契DP】HDU 4639——HeHe

    题目:点击打开链接 多校练习赛4的简单题,但是比赛的时候想到了推导公式f(n)=f(n-1)+f(n-2)(就是斐波那契数列),最后却没做出来. 首先手写一下he(不是hehe)连续时的规律.0-1 ...

  9. hdu 4639 Hehe (dp)

    一道dp题,转移方程不是自己推出来的. 题目的意思是用‘qnmlgb’替换‘hehe’,可以替换也可以不替换,问有多少种情况. 如果结尾不是‘hehe’,那么dp[i]=dp[i-1],如果是是‘he ...

随机推荐

  1. oracle to_char 返回毫秒级

    select to_char(systimestamp,'yyyy-mm-dd hh24:mi:ssxff') time1, 关键在 systimestamp

  2. sicily 1063. Who's the Boss

    Time Limit: 1sec    Memory Limit:32MB  Description Several surveys indicate that the taller you are, ...

  3. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha's staff 思维

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6154 题意:在笛卡尔坐标系下,画一个面积至少为  n 的简单多边形,每次只能画一条边或者一个格子的对角 ...

  4. 2017多校第6场 HDU 6105 Gameia 博弈

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6105 题意:Alice和Bob玩一个游戏,喷漆!现在有一棵树上边的节点最开始都没有被染色.游戏规则是: ...

  5. canvas制作柱形图/折线图/饼状图,Konva写动态饼状图

    制作饼状图 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  6. MySQL5.6.32源码安装

      . 安装好--安装MySQL需要的包 yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc- ...

  7. linux 设置开机启动项两种方式

    原文链接:http://blog.csdn.net/karchar/article/details/52489572 有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务. 在解问题之前 ...

  8. 5:django 常用函数

    用django写view函数的时候,我们常常用到django.shortcuts里面的很多常用函数, 这节我们来看看这些函数的具体用法吧 render render(request, template ...

  9. sql查询语句查询顺序

    一 SELECT语句关键字的定义顺序 SELECT DISTINCT <select_list> FROM <left_table> <join_type> JOI ...

  10. redis之(四)redis的字符串类型的命令

    [一]获得符合规则的键名列表  -->命令  keys [pattern] -->keys命令需要遍历Redis中所有的键,当键的数量比较多会影响性能,生产环境不建议用 -->pat ...