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 ...
随机推荐
- Spring简单的文件配置
Spring简单的文件配置 “计应134(实验班) 凌豪” 一.Spring文件配置 spring至关重要的一环就是装配,即配置文件的编写,接下来我按刚才实际过程中一步步简单讲解. 首先,要在web. ...
- Hibernate之dynamic-update
问题:设置了dynamic-update, 可是事实上并没有按照期望进行了update. 案例代码如下: 1.持久化对象 package com.jdw.hibernate.entities; imp ...
- [LeetCode]题解(python):149-Max Points on a Line
题目来源: https://leetcode.com/problems/max-points-on-a-line/ 题意分析: 在一个2D的板上面有很多个点,判断最多有多少个点在同一条直线上. 题目思 ...
- JS获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度
网页可见区域宽:document.body.clientWidth 网页可见区域高:document.body.clientHeight 网页可见区域宽:document.body.offsetWid ...
- J2SE知识点摘记(二十五)
Set 1.5.1 概述 Java 中的Set和正好和数学上直观的集(set)的概念是相同的.Set最大的特性就是不允许在其中存放的元素是重复的.根据这个特点,我们就可以使用Set 这个 ...
- poj2231---暴力
#include<stdio.h> #include<stdlib.h> #include<math.h> ]; int cmp(const void *a,con ...
- Python开发技术详解(视频+源码+文档)
Python, 是一种面向对象.直译式计算机程序设计语言.Python语法简捷而清晰,具有丰富和强大的类库.它常被昵称为胶水语言,它能够很轻松的把用其他语言制作的各种模块(尤其是C/C++)轻松地联结 ...
- findOneAndUpdate的用法详解
Fragment.findOneAndUpdate({_id:id}, {$set: datas}, {upsert:true, 'new':true}).populate('ads').exec(f ...
- ovs 实用案例
建立gre,xvlan:http://networkstatic.net/configuring-vxlan-and-gre-tunnels-on-openvswitch/ vm之间通过gre通信:h ...
- sass 语法实例
sass基本语法 1.定义一个变量,变量定义以$开头,以冒号分隔开. $blue:#1875e7; div{ color:$blue; } 编译之后的css代码: div { color: #1875 ...