POJ 1942:Paths on a Grid
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 22918 | Accepted: 5651 |
Description
your time with drawing modern art instead.
Fortunately you have a piece of squared paper and you choose a rectangle of size n*m on the paper. Let's call this rectangle together with the lines it contains a grid. Starting at the lower left corner of the grid, you move your pencil to the upper right corner,
taking care that it stays on the lines and moves only to the right or up. The result is shown on the left:

Really a masterpiece, isn't it? Repeating the procedure one more time, you arrive with the picture shown on the right. Now you wonder: how many different works of art can you produce?
Input
Output
You may safely assume that this number fits into a 32-bit unsigned integer.
Sample Input
5 4
1 1
0 0
Sample Output
126
2
给了一个n*m的格子,要从左下走到右上,问有多少种走法。
一共一定是走n+m步,这其中又必然有n步向上,m步向右。所以结果就是C[n+m][n]或者C[n+m][m]
代码:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#pragma warning(disable:4996)
using namespace std; unsigned long long weight,height; int main()
{
unsigned long long small,lo;
unsigned long long i,j,result;
while(cin>>weight>>height)
{
if(weight+height==0)//被0 5这样的坑死 这样的输出1 之前我自己还先判断一下 然后输出0...
break;
small=min(weight,height);
lo=weight+height; result=1; for(i=lo,j=1;j<=small;i--,j++)
{
result = (result*i)/j;
} cout<<result<<endl;
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
POJ 1942:Paths on a Grid的更多相关文章
- POJ - 1942 D - Paths on a Grid
Imagine you are attending your math lesson at school. Once again, you are bored because your teacher ...
- [ACM] POJ 1942 Paths on a Grid (组合)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 21297 Accepted: 5212 ...
- tarjan算法求桥双连通分量 POJ 3177 Redundant Paths
POJ 3177 Redundant Paths Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12598 Accept ...
- 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 ...
- POJ 3177 Redundant Paths POJ 3352 Road Construction(双连接)
POJ 3177 Redundant Paths POJ 3352 Road Construction 题目链接 题意:两题一样的.一份代码能交.给定一个连通无向图,问加几条边能使得图变成一个双连通图 ...
- 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)$ 但 ...
- Paths on a Grid(简单组合数学)
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...
- Android BottomSheet:List列表或Grid网格展示(3)
Android BottomSheet:List列表或Grid网格展示(3) BottomSheet可以显示多种样式的底部弹出面板风格,比如常见的List列表样式或者Grid网格样式,以一个例子 ...
随机推荐
- simplecheck
环境:win10 工具:jadx .夜神模拟器.pycharm 下载好了之后加载到模拟器 输入正确的flag验证 加载到jadx.查看MainAtivity if语句进行验证是否正确,如果正确就输出y ...
- Git闪退问题
打开Git 会一闪而过.并出现一个错误的日志文件.自己尝试安装了几个不同的版本Git还是解决不了问题.后来自己在网上找了一些办法,并进行总结 1. 进入git目录下的bin目录执行rebase -b ...
- Redis详解(八)——企业级解决方案
Redis详解(八)--企业级解决方案 缓存预热 缓存预热就是系统上线后,提前将相关的缓存数据直接加载到缓存系统.避免在用户请求的时候,先查询数据库,然后再将数据缓存的问题!用户直接查询事先被预热的缓 ...
- 011.Delphi插件之QPlugins,延时加载服务
这个DEMO是是把DLL插件的相关信息做成了一个配置文件,主程序加载这个配置文件,从而起到延时加载的作用 主程序代码如下 unit Frm_Main; interface uses Winapi.Wi ...
- SQL中Left Join 与Right Join 与 Inner Join 与 Full Join的区别
原文:http://blog.csdn.net/shadowyelling/article/details/7684714 Left Join : 返回左表中的全部信息 以及右表中与左表条件相关的信息 ...
- Webstorm常用快捷键备忘
WebStorm 是jetbrains公司旗下一款JavaScript 开发工具.被广大中国JS开发者誉为“Web前端开发神器”.“最强大的HTML5编辑器”.“最智能的JavaSscript IDE ...
- 使用conda创建虚拟环境
conda创建python虚拟环境 前言 conda常用的命令: conda list 查看安装了哪些包. conda env list 或 conda info -e 查看当前存在哪些虚拟环境 co ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 字体图标(Glyphicons):glyphicon glyphicon-euro
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name ...
- sprintf与sscanf用法举例
一.sscanf 从tmp中读取a,b,c. int main(){ ]; int a; double b; ]; while(gets(tmp) != NULL){ sscanf(tmp, &quo ...
- Centos6 import tensorflow遇到的问题
1.ImportError: /lib64/libc.so.6: version `GLIBC_2.16' not found 解决办法:升级系统glibc库至2.17版本 首先在网上下载glibc- ...