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. WAMP Apache 2.5 配置虚拟主机

    1.在 Apache 的安装目录下 conf/httpd.conf 文件中搜索 hosts,去掉 Include 前面的 “#” 号后,即可启用虚拟主机. # Virtual hosts #Inclu ...

  2. OPENSOLARIS source

    http://blog.csdn.net/nemo2011/article/details/8543220 http://fxr.watson.org/fxr/source/?v=OPENSOLARI ...

  3. 《gdb调试之基础篇》

    <gdb调试之基础篇> http://blog.csdn.net/miss_acha/article/details/42346543

  4. 【bzoj4459】JSOI2013丢番图

    某JSOI夏令营出题人啊,naive! 你还是得学习个,搬这种原题不得被我一眼看穿? 求个n^2的约数除以二,向上取整. #include<bits/stdc++.h> using nam ...

  5. 【bzoj4567】SCOI2016背单词

    题号莫名喜感. 倒序建Trie,dfs这棵Trie,贪心一下,每次按照size排序计算贡献就好. #include<bits/stdc++.h> #define N 100010 #def ...

  6. linux命令(34):less命令

    1.命令格式: less [参数]  文件 2.命令功能: less 与 more 类似,但使用 less 可以随意浏览文件,而 more 仅能向前移动,却不能向后移动,而且 less 在查看之前不会 ...

  7. HDU 3669 Cross the Wall(斜率DP+预处理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3669 题目大意:有n(n<=50000)个矩形,每个矩形都有高和宽,你可以在墙上最多挖k个洞使得 ...

  8. Flask 知识总结

    阅读目录 第一篇:Flask基础知识介绍 第二篇:Flask扩展小结 第三篇:Flask 配置文件 第四篇:ORM.MySQL数据库连接池 第五篇:单例模式.蓝图Blueprint 第六篇:SQLAL ...

  9. Linux文件系统中/tmp的临时文件清理说明

    https://www.cnblogs.com/MonkeyAC/articles/3631401.html

  10. AC日记——[HNOI2010]BOUNCE 弹飞绵羊 洛谷 P3203

    [HNOI2010]BOUNCE 弹飞绵羊 思路: SBlct: 代码: #include <bits/stdc++.h> using namespace std; #define max ...