XTU1177 Grid--组合数
来源:互联网 发布:网络效应和锁定效应 编辑:程序博客网 时间:2024/06/05 03:19
题目描述
一个N*M的网格,从左下角沿格子线走到右上角,只能往右或者往上走,请问有多少种不同的路线?
输入多个样例,每行包含两个整数N,M(1≤N,M≤33);如果N和M为0表示输入结束。
输出
每个样例输出一行,为路线的数目。
样例输入
1 1
1 2
33 33
0 0
样例输出
2
3
7219428434016265740
解题思路
从左下角到右上角,向右走过的网格数必为m,向上走过的网格数必为n,所以实际上是求m个0和n个1的排列组数。
参考求组合数。
AC代码:
# include<stdio.h>long long int re[35][35];int main(){int n,m;while(~scanf("%d%d",&n,&m)&&n&&m){for(int i=1;i<=n;i++) re[i][0]=1;for(int i=1;i<=m;i++) re[0][i]=1;for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) re[i][j]=re[i-1][j]+re[i][j-1]; printf("%I64d\n",re[n][m]);}return 0;}
阅读全文
0 0
- XTU1177 Grid--组合数
- poj1942 Paths on a Grid(组合数)
- POJ 1942 Paths on a Grid 组合数
- poj 1942 Paths on a Grid(组合数模板)
- POJ 1942 Paths on a Grid 组合数的优化
- POJ 1942 Paths on a Grid(组合数公式)
- Hust oj 1123 Grid(组合数||dp)
- POJ1492——Paths on a Grid(组合数公式)
- TOJ 1407. Paths on a Grid(组合数)
- poj-1942-Paths on a Grid【组合数】
- POJ - 1942 D - Paths on a Grid 组合数
- POJ 1942 Paths on a Grid(求组合数)
- poj 1942 Paths on a Grid (求组合数)
- poj 1942 Paths on a Grid(组合数学--组合数)
- poj 1942 Paths on a Grid 求组合数mCn的方法
- 组合数的递归调用:poj 1942 Paths on a Grid
- POJ 1942 Paths on a Grid 组合数的应用 (计算路径总个数)
- 组合数
- 【转】对Finger-vein biometric identification using convolutional neural network的理解以及扩展应用
- 人为什么会走向平庸?
- 数据结构第五周项目-自建算法库链栈
- 349. Intersection of Two Arrays
- 算法-排序-快速排序
- XTU1177 Grid--组合数
- 看看什么时候被收录
- Spark核心RDD:foldByKey函数详解
- [leetcode] 26. Remove Duplicates from Sorted Array
- 每天一道LeetCode-----将数字集转成字母集,计算有多少种转换方式
- DOM、javaScript与HTML
- HDU P2089 不要62
- 排序算法集合
- jQuery结合layerUI框架随机抽号网页版