就是一个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的更多相关文章

  1. (动态规划)Worm -- hdu -- 2151

    http://acm.hdu.edu.cn/showproblem.php?pid=2151 Worm Time Limit: 1000/1000 MS (Java/Others)    Memory ...

  2. HDU 2151 Worm

    Worm Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submissi ...

  3. hdu 2151 Worm (DP)

    Worm Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  6. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  8. poj和hdu部分基础算法分类及难度排序

    最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...

  9. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

随机推荐

  1. Spring整合JUnit4测试使用注解引入多个配置文件

    转自:https://kanpiaoxue.iteye.com/blog/2151903 我们使用spring写junit单测的时候,有的时候我们的spring配置文件只有一个.我们在类的注释上面会这 ...

  2. Jsoup的简单的使用示例

    利用Jsoup中的相关方法实现网页中的数据爬去,本例子爬去的网页为比较流行的programmableweb中的mashup描述内容,然后为数据库中存在的mashup添加相应的描述. package c ...

  3. 关于chm提示 已取消到该网页的导航的解决方法

    下载了一个chm文件,打开提示“已取消到该网页的导航”,以前以为是文件有问题,下载其他的也是出现这种情况,于是网上搜了下,解决方法如下: 方法 1 1. 双击此 .chm 文件. 2. 在“打开文件安 ...

  4. C - Ilya and Sticks(贪心)

    Problem description In the evening, after the contest Ilya was bored, and he really felt like maximi ...

  5. MVC HtmlHelper扩展——实现分页功能

    MVC HtmlHelper扩展类(PagingHelper) using System; using System.Collections.Generic; using System.Collect ...

  6. css中max-width和min-width的应用

    max-width:从字面意思可以看出,是规定元素本身最大宽度,元素本身宽度应小于等于最大宽度值. min-width:从字面意思可以看出,是规定元素本身最小宽度,元素本身宽度应大于等于最小宽度值. ...

  7. 杭电2061WA 01

    #include<stdio.h> struct mem { char s[50]; double c; double f; }; int main() { struct mem x[60 ...

  8. 几个书本上不常见到的C语言函数

    函数名称:getcwd #include <unistd.h> char *getcwd(char *buf, size_t size); 作用:把当前目录的绝对地址保存到 buf 中,b ...

  9. BZOJ 1305: [CQOI2009]dance跳舞 网络最大流_二分答案_建模

    Description 一次舞会有n个男孩和n个女孩.每首曲子开始时,所有男孩和女孩恰好配成n对跳交谊舞.每个男孩都不会和同一个女孩跳两首(或更多)舞曲.有一些男孩女孩相互喜欢,而其他相互不喜欢(不会 ...

  10. 路飞学城Python-Day79

    27-url控制器之path方法 由于基于re_path的路径编写方式是重复性高的编写url,如果规则改变了,则对应的要去修改很多url,这样是很不方便的 所以采用Django2.0的path去编写u ...