How many ways
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
1.机器人一开始在棋盘的起始点并有起始点所标有的能量。
2.机器人只能向右或者向下走,并且每走一步消耗一单位能量。
3.机器人不能在原地停留。
4.当机器人选择了一条可行路径后,当他走到这条路径的终点时,他将只有终点所标记的能量。

如上图,机器人一开始在(1,1)点,并拥有4单位能量,蓝色方块表示他所能到达的点,如果他在这次路径选择中选择的终点是(2,4)
点,当他到达(2,4)点时将拥有1单位的能量,并开始下一次路径选择,直到到达(6,6)点。
我们的问题是机器人有多少种方式从起点走到终点。这可能是一个很大的数,输出的结果对10000取模。
对于每一组数据第一行输入两个整数n,m(1 <= n,m <= 100)。表示棋盘的大小。接下来输入n行,每行m个整数e(0 <= e < 20)。
#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的更多相关文章
- [LeetCode] Different Ways to Add Parentheses 添加括号的不同方式
Given a string of numbers and operators, return all possible results from computing all the differen ...
- [LeetCode] Decode Ways 解码方法
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- Decode Ways
https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z is being encoded to ...
- 【LeetCode】241. Different Ways to Add Parentheses
Different Ways to Add Parentheses Given a string of numbers and operators, return all possible resul ...
- [Leetcode] Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- 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 ...
- 241. Different Ways to Add Parentheses
241. Different Ways to Add Parentheses https://leetcode.com/problems/different-ways-to-add-parenthes ...
- Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the differen ...
- 【leetcode】Decode Ways(medium)
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
- [LintCode] Decode Ways 解码方法
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...
随机推荐
- swift之元组类型
一.元组类型是有N个任意类型的数据组成(N>=0),组成元组类型的数据可以称为“元素” 二.元组的定义 如:let position = (x:10.5,y:20) //两个元素的元组 l ...
- 数据挖掘-关联规则分析[ZZ]
1.什么是关联规则 "尿布与啤酒"的故事大家都有听过,这里就不罗嗦了. 按常规思维,尿布与啤酒风马牛不相及,若不是借助数据挖掘技术对大量交易数据进行挖掘分析,沃尔玛是不可能发现数据 ...
- QT5新手上路(1)安装
这几天学了一下windows下的QT,也不算什么心得吧,就是谈一下我的做法.希望看到这篇随笔的菜鸟们略有所得,少走弯路. 闲话少说,先说安装.首先是选版本,我用的是qt-opensource-wind ...
- c++ fstream中seekg()和seekp()的用法
转自:http://blog.sina.com.cn/s/blog_679f85d40100mysi.html 先说一下C语言中fseek()的功能: 函数原型:int fseek(FILE *fp, ...
- JVM - 内存溢出问题排查相关命令jcmd jmap
jcmd http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jcmd.html jcmd-l 列出正在执行的JAVA进程ID ...
- HTML注释的一些规范
HTMl里的一些注释符号 1.bady,head内部的注释:<!--放注释内容--> 2.css样式的注释:/*放注释的内容*/ 3.javascript注释 单行注释://放注释的内容 ...
- C# 时间与时间戳互转
/// <summary> /// 将c# DateTime时间格式转换为Unix时间戳格式 /// </summary> /// <param name="t ...
- C# DES
using System; //这个是使用DES的基础 using System.Security.Cryptography; //这个是处理文字编码的前提 using System.Text; // ...
- 以中断方式实现1s定时
中断方式比较特殊,需要使用单片机内部的中断处理机制,同时指定中断函数. #include <reg52.h> sbit LED = P0^; unsigned ; void main() ...
- Boost1.62+win7+VC2015编译
下载 通过boost官方网站, 或直接在source forge下载boost_1_62_0. 可选包 Zlib library, 环境变量: ZLIB_SOURCE bzip2, 环境变量: BZI ...