Paths on a Grid(规律)
| Time Limit: 1000MS | Memory Limit: 30000K | |
| Total Submissions: 23270 | Accepted: 5735 |
Description
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
Sample Input
5 4
1 1
0 0
Sample Output
126
2
题解:找规律,总共走了m+n步,从这m+n步中选m步向右,规律很容易找出来,但是却是无符号的32位;
代码:
#include<stdio.h>
#include<math.h>
const int MAXN=;
int main(){
__int64 N,ans;
int T;
scanf("%d",&T);
while(T--){
ans=;
scanf("%I64d",&N);
N++;
int flot=;
for(int i=;i<=sqrt(N);i++)if(N%i==)ans++;
printf("%I64d\n",ans);
}
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 ...
- 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 ...
随机推荐
- CreateFileMapping共享内存时添加Global的作用
来源:http://www.cnblogs.com/elvislogs/articles/ShareMemory.html 通常使用CreateFileMapping建立共享内存时名称中没有加入&qu ...
- 使用Notepad++开发python配置笔记
这是我在python学习过程中,收集整理的一些notepadd++环境配置方法. 1.配置制表符 Notepad++ ->"设置"菜单->"首选项" ...
- 函数指针 如:void (*oper)(ChainBinTreee *p)
在C语言中,一个函数总是占用一段连续的内存区,而函数名就是该函数所占内存区的首地址.我们可以把函数的这个首地址(或称入口地址)赋予一个指针变量,使该指针变量指向该函数.然后通过指针变量就可以找到并调用 ...
- 【Win7激活工具2013版下载】适用于旗舰版、家庭高级版等所有版本32/64位 OEM激活
虽然现在Win8已经发布了,但是身边总是还有一些朋友在用着Win7系统,而近期微软频繁的推送补丁包,导致之前的那些激活都失效了.找了网络上很多工具,之前的那些有的已经不能用了,激活不了,今天就推荐一些 ...
- C语言入门(13)——循环
在递归调用中,其实每次递归都是在重复做同样一件事,比如求阶乘就是把n乘到(n-1)!上然后把结果返回.虽说是重复,但每次做都稍微有一点区别(n的值不一样),这种每次都有点区别的重复工作称为迭代. 我们 ...
- iOS开发之主题皮肤
iOS开发之主题皮肤 分类: [iOS] 最近在开发一款[公交应用],里面有个模块涉及到主题设置,这篇文章主要谈一下个人的做法. 大概的步骤如下: (1):整个应用依赖于一个主题管理器,主题管理器根 ...
- Android setTag IllegalArgumentException
E/AndroidRuntime(19480): java.lang.IllegalArgumentException: The key must be an application-specific ...
- 【G-BLASTN 1.0正式发布】
[G-BLASTN 1.0正式发布]G-BLASTN使用GPU来加速NCBI-BLAST里的BLASTN模块,单块GTX780比四核CPU平均快6倍. http://www.comp.hkbu.edu ...
- PLSQLDeveloper过期要注册表
打开运行输入 regedit 打表注册表 删除 HKEY_CURRENT_USER\Software\Allround Automations HKEY_CURRENT_USER\Software\M ...
- html基础标签-1-pre预格式标签
pre预格式标签 code,tt标签 1 <!doctype html> 2 <html lang='zh-cn'> 3 <head> 4 <meta cha ...