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网格样式,以一个例子 ...
随机推荐
- 主机ping虚拟机失败。虚拟机ping主机,可以ping通。
原文:https://blog.csdn.net/ww1473345713/article/details/51490525 今天打开虚拟机,然后用Xshell远程连接,发现连接不上.按照以下顺序检查 ...
- CSS样式表——格式与选择器
1.分类 1)内联(写在标签内部) style="样式" 控制精确,代码重用性差 2)内嵌(在<head></head>中) <style type= ...
- git commit -m 和 git commit -am 区别
git commit -m 和 git commit -am 通常修改一个文件 并且将文件提交到本地分支的命令是: git add . git commit -m 'update' 以上两个命令其实可 ...
- 响应式布局之 px、em、 rem
一.写在前面的话 作为一面前端开发者,对 px .em . rem 应该是再熟悉不过了,但大多数小伙伴应该都和我一样仅仅停留在了解的层面,并不是实质性的掌握它们.本文对三者进行了详细的总结和详细说明, ...
- python -- 相对路径、绝对路径、以及路径的获取
1.定义 绝对路径:就是文件的真正存在的路径,是指从硬盘的根目录(盘符)开始,进行一级级目录指向文件. 相对路径:就是以当前文件为基准进行一级级目录指向被引用的资源文件. ../ 表示当前文件所在 ...
- MySQL报错注入函数汇总及常用注入语句
版权声明:本文转载自网络内容,下面附原创链接原创链接:https://blog.csdn.net/Auuuuuuuu/article/details/91415165 常用函数 字符串连接函数,将多个 ...
- Oracle SQL触发器
一.触发器 触发器是一个数据库对象,是一个特殊的过程,当特定的时间发生时隐式地执行.比如在一个表中发生插入.更新或删除的时间,或者 CREATE.ALTER 这样的数据定义语句执行时,触发器会隐式执行 ...
- python3调用微软js引擎ChakraCore
有关ChakraCore介绍请移步:https://github.com/Microsoft/ChakraCore 使用案例GitHub源码:https://github.com/pyAppman/C ...
- 028-PHP常用数学函数abs和acos和asin
<?php print(abs(-));//打印绝对值 // 从 -1 到1打印acos函数的值 print("<TABLE BORDER=\"1\"> ...
- 140-PHP类的抽象方法和继承
<?php abstract class father{ //定义一个抽象类 abstract public function test(); //定义抽象方法 } class son exte ...