poj 1942 Paths on a Grid 求组合数mCn的方法
2013-09-14 10:59
381 查看
unsigned int comb(unsigned a,unsigned b)
{
if(b > a-b)
b= a-b;
double result = 1;
while(b>0)
{
result *= (double)a / (double) b;
//cout<<"result:"<<result<<endl;
--a;
--b;
}
return ( unsigned int)(result + 0.5); //四舍五入
}
一个求组合数的函数
{
if(b > a-b)
b= a-b;
double result = 1;
while(b>0)
{
result *= (double)a / (double) b;
//cout<<"result:"<<result<<endl;
--a;
--b;
}
return ( unsigned int)(result + 0.5); //四舍五入
}
一个求组合数的函数
#include <iostream> #include <stdio.h> using namespace std; //C(a,b) // unsigned int comb(unsigned a,unsigned b) { if(b > a-b) b= a-b; double result = 1; while(b>0) { result *= (double)a / (double) b; //cout<<"result:"<<result<<endl; --a; --b; } return ( unsigned int)(result + 0.5); } int main() { unsigned int m,n; while(cin>>m>>n) { if(m==0&&n==0) break; cout<<comb(m+n,m)<<endl; } }
相关文章推荐
- poj 1942 Paths on a Grid 简单排列组合 + unsigned long long 使用方法
- poj-1942-Paths on a Grid【组合数】
- POJ 1942-Paths on a Grid(组合数学)
- POJ 1942 Paths on a Grid【组合数学】
- 【poj 1942】Paths on a 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 (组合数学)
- POJ 题目1942 Paths on a Grid(排列组合,水)
- POJ 1942 Paths on a Grid【组合数学】
- [ACM] POJ 1942 Paths on a Grid (组合)
- Paths on a Grid POJ 1942 组合数学
- POJ - 1942 D - Paths on a Grid 组合数
- POJ 1942 Paths on a Grid (组合数学)
- poj 1942 Paths on a Grid(组合数学--组合数)
- POJ1942——Paths on a Grid(组合数学)
- POJ1942 Paths on a Grid (组合数学)
- POJ 1942 Paths on a Grid (组合数学)