POJ 1942 Paths on a Grid
// n*m 的格子 从左下角走到右上角的种数
// 相当于从 n+m 的步数中选 m 步往上走
// C(n+m,m)
#include <iostream>
#include <string>
#include<sstream>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define LL long long
LL C(LL n,LL k)
{
LL m=;
if(k>n/) k=n-k; // 不加这句会超时 比如C[10^9][10^9 - 1]
int i;
for(i=;i<=k;i++)
{
m*=(n-i+);
m/=i;
}
return m;
}
int main()
{
LL n,k;
while(scanf("%lld %lld",&n,&k),n|k)
{
printf("%lld\n",C(n+k,k));
}
return ;
}
POJ 1942 Paths on a Grid的更多相关文章
- [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(组合数)
http://poj.org/problem?id=1942 题意 :在一个n*m的矩形上有n*m个网格,从左下角的网格划到右上角的网格,沿着边画,只能向上或向右走,问有多少条不重复的路 . 思路 : ...
- poj 1924 Paths on a Grid(组合数学)
题目:http://poj.org/problem?id=1942 题意:给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有 ...
- POJ 1942:Paths on a Grid
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 22918 Accepted: 5651 ...
- 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)$ 但 ...
- poj——3177Redundant Paths
poj——3177Redundant Paths 洛谷—— P2860 [USACO06JAN]冗余路径Redundant Paths Time Limit: 1000MS Memory ...
随机推荐
- Windows服务创建及安装
Windows服务创建及安装http://www.cnblogs.com/tuyile006/archive/2006/11/27/573654.html
- Codeforces Round #260 (Div. 2) A~C
题目链接 A. Laptops time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputo ...
- Xamarin for Visual Studio 3.11.666 稳定版 破解补丁 Version 3
前提概要 1.全新安装请参考 安装 Xamarin for Visual Studio. 2.本次补丁包含: ① Xamarin for Visual Studio 3.11.666 ② Xamari ...
- StructLayout特性(转)
StructLayout特性 StructLayout特性 公 共语言运行库利用StructLayoutAttribute控制类或结构的数据字段在托管内存中的物理布局,即类或结构需要 ...
- redis系列之Redis应用场景
1 取最新N个数据的操作 比如典型的取你网站的最新文章,通过下面方式,我们可以将最新的5000条评论的ID放在Redis的List集合中,并将超出集合部分从数据库获取 1)使用LPUSH latest ...
- 【转】terminal 快捷键
转自:http://www.jb51.net/os/Ubuntu/141723.html 1.gnome-terminal快捷键设置方法: 系统 —> 首选项 ->键盘快捷键 -> ...
- C逻辑型变量——时控灯例子
在C99标准颁布之前,我们通常都是用1或者0来表示逻辑的真与假,因此,当我们需要在程序中传递这种逻辑数据时,我们都是用整型数据类型int来表示这种逻辑型数据.然而,使用整型数据类型int来表示逻辑型变 ...
- Java-马士兵设计模式学习笔记-观察者模式-模拟Awt Button
一.概述 Java 的Awt是 Observer模式,现用Java自己模拟awt中Button的运行机制 二.代码 1.Test.java import java.text.DateFormat; i ...
- mysql 支持中文,防止程序乱码的方法
1. 查看你的mysql的字符设置 mysql> show variables like 'character%'; +--------------------------+---------- ...
- jQuery:balloon气泡提示插件
插件下载地址:http://file.urin.take-uma.net/jquery.balloon.js-Demo.html <!DOCTYPE html PUBLIC "-//W ...