Paths on a Grid
http://poj.org/problem?id=1942
题意:一个n*m的格子,从左下角走到右上角有多少种走法,规定只能向上或向右走;
思路:解法挺水的,高中学组合数的时候老师给讲过;求C[m+n][n]就可以;
但是这里n,m是32位以内的数,要用double,输出的时候只输出整数部分;
#include<iostream>
#include<iomanip>
using namespace std; double n,m,ans;
int main()
{
cout<<fixed<<setprecision();
while(cin>>n>>m)
{
if(n == && m == )
break;
if(n > m) swap(n,m); ans = ;
for(unsigned i = ; i <= n; i++)
{
ans = ans*(m+i)/i;
}
cout<<ans<<endl;
}
return ;
}
Paths on a Grid的更多相关文章
- Paths on a Grid(简单组合数学)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...
- POJ1942——Paths on a Grid(组合数学)
Paths on a Grid DescriptionImagine you are attending your math lesson at school. Once again, you are ...
- Paths on a Grid(规律)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23270 Accepted: 5735 ...
- poj1942 Paths on a Grid(无mod大组合数)
poj1942 Paths on a Grid 题意:给定一个长m高n$(n,m \in unsigned 32-bit)$的矩形,问有几种走法.$n=m=0$时终止. 显然的$C(m+n,n)$ 但 ...
- [ACM] POJ 1942 Paths on a Grid (组合)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21297 Accepted: 5212 ...
- POJ 1942:Paths on a Grid
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 22918 Accepted: 5651 ...
- POJ - 1942 D - Paths on a Grid
Imagine you are attending your math lesson at school. Once again, you are bored because your teacher ...
- Paths on a Grid(poj 1942)
给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有多少种走法,每步只能向上或者向右走. //注意循环的时候,要循环小的数,否 ...
- poj1942 Paths on a Grid
处理阶乘有三种办法:(1)传统意义上的直接递归,n的规模最多到20+,太小了,在本题不适用,而且非常慢(2)稍快一点的算法,就是利用log()化乘为加,n的规模虽然扩展到1000+,但是由于要用三重循 ...
- POJ 1942 Paths on a Grid
// n*m 的格子 从左下角走到右上角的种数// 相当于从 n+m 的步数中选 m 步往上走// C(n+m,m) #include <iostream> #include <st ...
随机推荐
- javascript中涉及到汉字的比较
在使用js中的"=="进行字符串的比较时,发现在英文情况下是ok的,但在中文比较时则不行了. 在网上搜索,提供了一个解决方法,使用 stringObject.localeCompa ...
- Spring 3 MVC: Themes In Spring-Tutorial With Example---reference
Welcome to Part 6 of Spring 3.0 MVC Series. In previous article we saw how to add Internationalizati ...
- [转] npm 模块安装机制简介
npm 是 Node 的模块管理器,功能极其强大.它是 Node 获得成功的重要原因之一. 正因为有了npm,我们只要一行命令,就能安装别人写好的模块 . $ npm install 本文介绍 npm ...
- JAVA 原始国际化例子
import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; public cla ...
- Maven学习总结——聚合与继承
一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模块一</module&g ...
- 10.11 noip模拟试题
4题均为128M,1s 1. 锻炼计划(exercise.pas) 身体是革命的本钱,OIers不要因为紧张的学习和整天在电脑前而忽视了健康问题.小x设计了自己的锻炼计划,但他不知道这个计划是否可行, ...
- (转)webstorm快捷键
Ctrl+N 查找类 Ctrl+Shift+N 查找文件 Ctrl+Alt+L 格式化代码 Ctrl+Alt+O 优化导入的类和包 Alt+Insert 生成代码(如get,set方法,构造函数等) ...
- Css3渐变实例Demo(一)
1.指定渐变背景的大小 .div { background: url(../img/1.jpg); /*background-size:contain;*/ width: 500px; height: ...
- android 蓝牙4.0 开发介绍
最近一直在研究一个蓝牙功能 由于本人是菜鸟 学起来比较忙 一直搞了好久才弄懂 , 网上对蓝牙4.0也就是几个个dome 抄来抄去,全是英文注解 , 对英语不好的朋友来说 真是硬伤 , 一些没必要的描 ...
- newInstance()和new的区别
在初始化一个类,生成一个实例的时候:newInstance() 和 new 有什么区别?用newInstance与用new是有区别的,区别在于创建对象的方式不一样,前者是使用类加载机制,那么为什么会有 ...