poj 1942 Paths on a Grid 求组合数mCn的方法
来源:互联网 发布:中山广电网络客服电话 编辑:程序博客网 时间:2024/05/22 05:24
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); //四舍五入
}
一个求组合数的函数
#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 求组合数mCn的方法
- 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(组合数公式)
- 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(组合数学--组合数)
- poj1942 Paths on a Grid(组合数)
- poj 1942 Paths on a Grid 组合数学
- Paths on a Grid POJ 1942 组合数学
- POJ 1942 Paths on a Grid(组合数学)
- POJ 1942 Paths on a Grid 组合以及处理阶乘
- [ACM] POJ 1942 Paths on a Grid (组合)
- 智能指针boost::shared_ptr
- TCP传输连接建立与释放详解
- Storm入门
- ffmpeg output_example.c 例程分析
- 关于larbin useragent 与 robot.txt设置
- poj 1942 Paths on a Grid 求组合数mCn的方法
- RMAN 备份详解
- 2.6 内核中的计时器 小结
- javascript 字符串相关方法的使用(toUppercase,charAT,substring)
- .net MVC4学习记录
- xfire发布webservice接口
- 华为2012年上机-字符串四则运算
- POJ 2242另一种方式求周长
- 『openframeworks』动物眼中的你-shader初试