How many ways

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2121    Accepted Submission(s): 1279

Problem Description
这是一个简单的生存游戏,你控制一个机器人从一个棋盘的起始点(1,1)走到棋盘的终点(n,m)。游戏的规则描述如下:
1.机器人一开始在棋盘的起始点并有起始点所标有的能量。
2.机器人只能向右或者向下走,并且每走一步消耗一单位能量。
3.机器人不能在原地停留。
4.当机器人选择了一条可行路径后,当他走到这条路径的终点时,他将只有终点所标记的能量。

如上图,机器人一开始在(1,1)点,并拥有4单位能量,蓝色方块表示他所能到达的点,如果他在这次路径选择中选择的终点是(2,4)

点,当他到达(2,4)点时将拥有1单位的能量,并开始下一次路径选择,直到到达(6,6)点。
我们的问题是机器人有多少种方式从起点走到终点。这可能是一个很大的数,输出的结果对10000取模。

 
Input
第一行输入一个整数T,表示数据的组数。
对于每一组数据第一行输入两个整数n,m(1 <= n,m <= 100)。表示棋盘的大小。接下来输入n行,每行m个整数e(0 <= e < 20)。
 
Output
对于每一组数据输出方式总数对10000取模的结果.
 
Sample Input
1
6 6
4 5 6 6 4 3
2 2 3 1 7 2
1 1 4 6 2 7
5 8 4 3 9 5
7 6 6 2 1 5
3 1 1 3 7 2
 
Sample Output
3948
 #include<stdio.h>
#include<string.h>
int a[][],dp[][];
int main()
{
int T,n,m,i,j,t,p;
scanf("%d",&T);
while(T--)
{
memset(dp,,sizeof(dp));
dp[][] = ;
scanf("%d%d",&n,&m);
for(i = ;i < n;i ++)
{
for(j = ;j < m;j ++)
{
scanf("%d",&a[i][j]);
for(t = ;t <= a[i][j];t ++)
{
for(p = ;p <= a[i][j]-t;p ++)
{
if(t!=||p!=)
dp[i+t][j+p] = (dp[i+t][j+p]+dp[i][j])%;
}
}
}
}
printf("%d\n",dp[n-][m-]);
}
return ;
}

How many ways的更多相关文章

  1. [LeetCode] Different Ways to Add Parentheses 添加括号的不同方式

    Given a string of numbers and operators, return all possible results from computing all the differen ...

  2. [LeetCode] Decode Ways 解码方法

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  3. Decode Ways

    https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encoded to ...

  4. 【LeetCode】241. Different Ways to Add Parentheses

    Different Ways to Add Parentheses Given a string of numbers and operators, return all possible resul ...

  5. [Leetcode] Decode Ways

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  6. Three ways to set specific DeviceFamily XAML Views in UWP

    Three ways to set specific DeviceFamily XAML Views in UWP http://igrali.com/2015/08/02/three-ways-to ...

  7. 241. Different Ways to Add Parentheses

    241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...

  8. Different Ways to Add Parentheses

    Given a string of numbers and operators, return all possible results from computing all the differen ...

  9. 【leetcode】Decode Ways(medium)

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  10. [LintCode] Decode Ways 解码方法

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

随机推荐

  1. swift之元组类型

    一.元组类型是有N个任意类型的数据组成(N>=0),组成元组类型的数据可以称为“元素” 二.元组的定义 如:let position = (x:10.5,y:20)    //两个元素的元组 l ...

  2. 数据挖掘-关联规则分析[ZZ]

    1.什么是关联规则 "尿布与啤酒"的故事大家都有听过,这里就不罗嗦了. 按常规思维,尿布与啤酒风马牛不相及,若不是借助数据挖掘技术对大量交易数据进行挖掘分析,沃尔玛是不可能发现数据 ...

  3. QT5新手上路(1)安装

    这几天学了一下windows下的QT,也不算什么心得吧,就是谈一下我的做法.希望看到这篇随笔的菜鸟们略有所得,少走弯路. 闲话少说,先说安装.首先是选版本,我用的是qt-opensource-wind ...

  4. c++ fstream中seekg()和seekp()的用法

    转自:http://blog.sina.com.cn/s/blog_679f85d40100mysi.html 先说一下C语言中fseek()的功能: 函数原型:int fseek(FILE *fp, ...

  5. JVM - 内存溢出问题排查相关命令jcmd jmap

    jcmd http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jcmd.html jcmd-l  列出正在执行的JAVA进程ID ...

  6. HTML注释的一些规范

    HTMl里的一些注释符号 1.bady,head内部的注释:<!--放注释内容--> 2.css样式的注释:/*放注释的内容*/ 3.javascript注释 单行注释://放注释的内容 ...

  7. C# 时间与时间戳互转

    /// <summary> /// 将c# DateTime时间格式转换为Unix时间戳格式 /// </summary> /// <param name="t ...

  8. C# DES

    using System; //这个是使用DES的基础 using System.Security.Cryptography; //这个是处理文字编码的前提 using System.Text; // ...

  9. 以中断方式实现1s定时

    中断方式比较特殊,需要使用单片机内部的中断处理机制,同时指定中断函数. #include <reg52.h> sbit LED = P0^; unsigned ; void main() ...

  10. Boost1.62+win7+VC2015编译

    下载 通过boost官方网站, 或直接在source forge下载boost_1_62_0. 可选包 Zlib library, 环境变量: ZLIB_SOURCE bzip2, 环境变量: BZI ...