poj1942 Paths on a Grid
来源:互联网 发布:人工智能 高端服务业 编辑:程序博客网 时间:2024/06/05 10:09
*题意:
在给定的方格中,按照只能向右向上的格式,求有几种方式可以从左下方到右上方。
分析:
根据方格的规模,m×n,肯定向右m次,向上n次,所以问题转化为从m+n步中选取m步向右(剩余的n步 自然向上)。
在求组合是尽量简化运算。
*代码:
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){long long int a,b,m,n,ans,count;while(cin>>a>>b){if(a==0&&b==0)break;m=a;n=a+b;ans=1;if(m>n-m)m=n-m;count=m;while(count--){ans*=n--;while(ans%m==0&&m>1)ans/=m--;}cout<<ans<<endl;}return 0;}
- poj1942 Paths on a Grid
- poj1942 Paths on a Grid
- poj1942 Paths on a Grid
- poj1942 Paths on a Grid 【排列组合】
- poj1942 Paths on a Grid(组合数)
- POJ1942 Paths on a Grid (组合数学)
- POJ1942——Paths on a Grid
- poj1942--Paths on a Grid(组合篇4)
- poj1942——Paths on a Grid(求阶乘)
- poj1942——Paths on a Grid//大数的C(n,m)
- Paths on a Grid
- Paths on a Grid
- Paths on a Grid
- pku1942 Paths on a Grid
- pku1942-Paths on a Grid
- poj 1942 Paths on a Grid
- POJ 1942 Paths on a Grid
- POJ 1942 Paths on a Grid .
- Matlab函数
- matlab运用fft进行简单的滤波
- Codeforces Beta Round #5
- J2EE基础的一些了解
- linux虚拟文件系统浅析
- poj1942 Paths on a Grid
- 卦卦学mysql系列(3)——mysql入门 数据表内的操作
- 我什么都不会网络系统架构
- Poj 3461 Oulipo(KMP算法)
- J2EE中的13种技术规范
- suid
- JNI 入门介绍(jstring与char*的转换)
- iphone -- Notification使用
- 冒烟测试