Unique Paths 不同的路径 DP
2015-04-16 17:42
260 查看
Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
Above is a 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.
class Solution { public: int uniquePaths(int m, int n) { int i,j,dp[101][101]; memset(dp,0,sizeof(dp)); for(i=1;i<=n;i++) dp[1][i]=1; for(i=1;i<=m;i++) dp[i][1]=1; for(i=2;i<=m;i++) { for(j=2;j<=n;j++) dp[i][j]=dp[i-1][j]+dp[i][j-1]; } return dp[m] ; } };
相关文章推荐
- Leet Code 62 Unique Paths - 不同路径 - Java
- LeetCode OJ 之 Unique Paths (不同路径)
- hdu6035 Colorful Tree 树形dp 给定一棵树,每个节点有一个颜色值。定义每条路径的值为经过的节点的不同颜色数。求所有路径的值和。
- [LeetCode] Unique Paths 不同的路径
- leetcode62.[DP] Unique Paths
- JS Cookie 路径问题(发现在不同的目录下,调用同一个js方法来存储Cookie,到别的目录取不出或取出的值是不对的)
- BZOJ1907: 树的路径覆盖 树形DP
- hdu FatMouse's Speed(DP)(打印路径)
- IE和chrome中,windows.location.href的不同跳转路径的解决方式
- HDU 1723-Distribute Message-dp-(有向图路径模型)
- css和javascript中图片路径的不同(原创教程)
- Java在不同环境下获取当前路径的方法
- C#中几种不同路径表示在网域和本地的差异
- ORACLE 10g将数据文件,日志文件和控制文件迁移到不同的路径
- 几种不同的多路径软件查看多路径状态的方法
- hdu 5092 Seam Carving dp+记录路径
- lintcode-115-不同的路径 II
- 拓扑排序&关键路径&数位dp
- 区间dp模型之括号匹配打印路径 poj(1141)