LEETCODE: Unique Paths
来源:互联网 发布:nsp网络 编辑:程序博客网 时间:2024/06/13 05:12
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?
幸亏long long 可以搞定,不过数量更多之后,还是需要其他办法。class Solution {public: int uniquePaths(int m, int n) { if(m == 1 || n == 1) return 1; int down = m + n - 2; int up = m < n ? m - 1 : n -1; long long totaldown = 1; long long totalup = 1; for(int ii = up; ii > 0; ii --) { totaldown *= down; totalup *= up; down --; up --; } return totaldown / totalup; }};
0 0
- leetcode Unique Paths && Unique Paths
- Leetcode-Unique Paths&Unique PathsII
- [LeetCode] Unique Paths and Unique Paths II
- leetcode--Unique Paths && Unique Paths ii
- leetcode--Unique Paths && Unique Paths ii
- 【Leetcode】【python】Unique Paths/Unique Paths II
- LeetCode: Unique Paths
- LeetCode: Unique Paths II
- [Leetcode] Unique Paths
- [Leetcode] Unique Paths II
- LeetCode : Unique Paths
- LeetCode : Unique Paths II
- leetcode 9: Unique Paths
- [LeetCode] Unique Paths
- [LeetCode] Unique Paths II
- [LeetCode]Unique Paths
- [LeetCode]Unique Paths II
- [LeetCode] Unique Paths
- git 使用
- 解决Please ensure that adb is correctly located at 'D:\java\sdk\platform-tools\adb.exe' and can be exe
- julycoding/The-Art-Of-Programming-By-July
- ExtJS 4 数据(包)详解 - ExtJS4中文教程
- 引用作形参--输入三个整数,按从大到小排序
- LEETCODE: Unique Paths
- WPF之DataGrid应用
- android 布局相关知识
- eclipse 解决乱码问题
- 第十七周项目7 电子词典(还有疑问,求解答)
- SurfaceView实现视频播放
- HDU 1860 - Currency Exchange(最短路)
- soaplib之model?
- ssh连接linux