HDU-4639 Hehe 简单DP
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4639
简单递推题,呵呵,不多说。。。
//STATUS:C++_AC_15MS_272KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef __int64 LL;
typedef unsigned __int64 ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
const LL LNF=1LL<<;
const double EPS=1e-;
const double OO=1e15;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End char s[N];
int f[N];
int T; int main(){
// freopen("in.txt","r",stdin);
int Ca=,i,j,cnt,ans,n,ok;
f[]=,f[]=;
for(i=;i<N;i++)
f[i]=(f[i-]+f[i-])%MOD;
scanf("%d",&T);
while(T--)
{
scanf("%s",s);
n=strlen(s);
ans=;ok=;
for(i=;i<n;){
if(s[i]!='h' || s[i+]!='e'){
i++;
continue;
}
for(cnt=;i<n- && s[i]=='h' && s[i+]=='e';i+=,cnt++);
ans=(ans*f[cnt])%MOD;
} printf("Case %d: %d\n",Ca++,ans);
}
return ;
}
HDU-4639 Hehe 简单DP的更多相关文章
- hdu 4639 Hehe (dp)
一道dp题,转移方程不是自己推出来的. 题目的意思是用‘qnmlgb’替换‘hehe’,可以替换也可以不替换,问有多少种情况. 如果结尾不是‘hehe’,那么dp[i]=dp[i-1],如果是是‘he ...
- 【斐波那契DP】HDU 4639——HeHe
题目:点击打开链接 多校练习赛4的简单题,但是比赛的时候想到了推导公式f(n)=f(n-1)+f(n-2)(就是斐波那契数列),最后却没做出来. 首先手写一下he(不是hehe)连续时的规律.0-1 ...
- hdu 4639 Hehe
http://acm.hdu.edu.cn/showproblem.php?pid=4639 每一段 "hehe..... " 相互独立 将每一段 "hehe..... ...
- hdu 4576 (简单dp+滚动数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4576 题意:给出1~n的环,m个操作,每次能顺时针或逆时针走w步,询问最后在l~r这段区间内概率.(1 ...
- HDU 4639 Hehe (2013多校4 1008 水题)
Hehe Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU 2836 Traversal 简单DP + 树状数组
题意:给你一个序列,问相邻两数高度差绝对值小于等于H的子序列有多少个. dp[i]表示以i为结尾的子序列有多少,易知状态转移方程为:dp[i] = sum( dp[j] ) + 1;( abs( he ...
- hdu 5569 matrix(简单dp)
Problem Description Given a matrix with n rows and m columns ( n+m ,) and you want to go to the numb ...
- HDU 4639 Hehe 2013 Multi-University Training Contest 4
题意大致如下:屌丝找女神聊天,女神回了一句 hehe ,而我们都知道 Hehe 有两个意思,一个就是 Hehe ,另外一个则是 wqnmlgb (我去年买了个表) ,所以屌丝很纠结,于是开始思考到底女 ...
- HDU 4639 hehe 杭电2013多校联赛第四场1008题
解题报告:题目的意思是输入一个字符串,并规定,里面的“hehe”可以用"wqnmlgb"来代替,也可以不代替,问输入的这个字符串在经过相关的代替之后可以有多少种不同的形态.先打一个 ...
随机推荐
- uva 825
这个......小学生就会的 坑在输入输出了 两个数之间可能不止一个空格....wa了好几遍啊 #include <cstdio> #include <cstring> # ...
- java去掉List中的重复值代码
1. list中为字符串的情况,代码如下: public static void main(String[] args) { List<String> li = new ArrayList ...
- YUV格式详解
What is YUV YUV,是一种颜色编码方法. YUV是编译true-color颜色空间(color space)的种类,Y'UV, YUV, YCbCr,YPbPr等专有名词都可以称为YUV, ...
- VC 最爱问的问题:你这个创业项目,如果腾讯跟进了,而且几乎是产品上完全复制,你会怎么办?
VC 最爱问的问题:你这个创业项目,如果腾讯跟进了,而且几乎是产品上完全复制,你会怎么办? http://www.zhihu.com/question/19607233 朱继玉,独立精神,自由思想. ...
- Android 文字链接 文字点击时的背景颜色
案例:实现“忘记密码?”这个链接,并且在按下的时候改变颜色. 方法一:这个可以用TextView实现: 主界面main.xml: <?xml version="1.0" en ...
- LinkedList源代码深入剖析
第1部分 LinkedList介绍LinkedList简介 public class LinkedList<E> extends AbstractSequentialList<E&g ...
- Linux下的动态连接库及其实现机制
Linux与Windows的动态连接库概念相似,但是实现机制不同.它引入了GOT表和PLT表的概念,综合使用了多种重定位项,实现了"浮动代码",达到了更好的共享性能.本文对这些技术 ...
- eclipse不自动弹出提示(Alt+/ 快捷键失效)
转自:http://www.cnblogs.com/shaweng/archive/2013/09/26/3340016.html 主要有一下几种方法: 1.次方法用于没有一点提示的情况:依次打 ...
- hdu 1412 (STL list)
简单例题 题目:http://acm.hdu.edu.cn/showproblem.php?pid=1412 list 相关博客:http://www.cnblogs.com/fangyukuan/a ...
- jsoi2015 R2——滚粗记
考完感觉各种绝望溢出胸口,作为百度空间的最后一篇文章了吧 day 0 第二轮在南师附中……不能到外地玩了…… 其实在试机的时候就感觉不大对头,明明说好18:15试机结果拖到18:30…… 还有今年竟然 ...