hdu 2151
就是一个dp,数组内存的步数,
数组没清空,wa了一次
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int step[110][110];
int main()
{
int N,P,M,T;
while(scanf("%d%d%d%d",&N,&P,&M,&T)!=EOF){
memset(step,0,sizeof(step));
step[0][P]=1;
for(int i=1;i<=M;i++){
for(int j=1;j<=N;j++){
if(step[i-1][j+1]!=0&&j+1<=N) step[i][j]+=step[i-1][j+1];
if(step[i-1][j-1]!=0&&j-1>=1) step[i][j]+=step[i-1][j-1]; }
}
// for(int i=1;i<=M;i++){
// for(int j=1;j<=N;j++){
// printf("%d ",step[i][j]);
// }
// printf("\n");
// }
printf("%d\n",step[M][T]);
}
return 0;
}
hdu 2151的更多相关文章
- (动态规划)Worm -- hdu -- 2151
http://acm.hdu.edu.cn/showproblem.php?pid=2151 Worm Time Limit: 1000/1000 MS (Java/Others) Memory ...
- HDU 2151 Worm
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...
- hdu 2151 Worm (DP)
Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- poj和hdu部分基础算法分类及难度排序
最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
随机推荐
- 用dom4j解析xml文件并执行增删改查操作
转自:https://www.aliyun.com/jiaocheng/1339446.html xml文件: <?xml version="1.0" encoding=&q ...
- H3C路由器查看序列号信息
H3C MSR系列的路由器,查看本机的MAC地址.序列号信息和生产日期信息等可以使用dis device manuinfo 命令查看,以下是执行结果: slot 0 DEVICE_NAME ...
- Linux下JDK Tomcat MySQL基本环境搭建
1. 安装JDK wget http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1 ...
- kindeditor文本编辑器乱码中乱码问题解决办法
这个问题我已经解决掉了,不是更改内容的编码格式,只要将lang/zh_CN.js 这个文件的编码转换成unicode即可 操作方法是 用记事本打开这个文件,另存为,然后更改文件的编码格式为unico ...
- CSS vs. JS Animation: 哪个更快
CSS vs. JS Animation: 哪个更快? CSS vs. JS Animation: 哪个更快? 基于JavaScript的动画竟然已经默默地比CSS的transition动画快了?而且 ...
- Ruby. Vs . Python
前言:从语言的本质上来分析,我对Ruby持反对态度,毕竟语言是为了交流,在表达的效率层面为了正确性必须适当放弃复杂性.且有句老话说的好,Ruby In Rails 才是语言,而Ruby只是这个语言的工 ...
- matplotlib学习笔记.CookBook
matplotlib 是Python下的一个高质量的画图库,可以简单的类似于MATLAB方法构建高质量的图表. 原始文章地址:http://zanyongli.i.sohu.com/blog/view ...
- WebLogic安装使用及常见问题
WebLogic的下载与安装 下载地址: http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html fmw_ ...
- iframe里面开启全屏allowfullscreen="true"
<iframe id="J_iframe" width="100%" height="100%" src="client-a ...
- mac上安装flask详细步骤
1 在终端输入 macdeMac-mini-62:~ mac$ sudo easy_install pip 2 macdeMac-mini-62:~ mac$ sudo pip install fl ...