// 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的更多相关文章

  1. [ACM] POJ 1942 Paths on a Grid (组合)

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 21297   Accepted: 5212 ...

  2. POJ 1942 Paths on a Grid(组合数)

    http://poj.org/problem?id=1942 题意 :在一个n*m的矩形上有n*m个网格,从左下角的网格划到右上角的网格,沿着边画,只能向上或向右走,问有多少条不重复的路 . 思路 : ...

  3. poj 1924 Paths on a Grid(组合数学)

    题目:http://poj.org/problem?id=1942 题意:给定一个矩形网格的长m和高n,其中m和n都是unsigned int32类型,一格代表一个单位,就是一步,求从左下角到右上角有 ...

  4. POJ 1942:Paths on a Grid

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 22918   Accepted: 5651 ...

  5. Paths on a Grid(简单组合数学)

    Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Desc ...

  6. POJ1942——Paths on a Grid(组合数学)

    Paths on a Grid DescriptionImagine you are attending your math lesson at school. Once again, you are ...

  7. Paths on a Grid(规律)

    Paths on a Grid Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 23270   Accepted: 5735 ...

  8. 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)$ 但 ...

  9. poj——3177Redundant Paths

    poj——3177Redundant Paths      洛谷—— P2860 [USACO06JAN]冗余路径Redundant Paths Time Limit: 1000MS   Memory ...

随机推荐

  1. Windows 回调监控 <二>

    在之前的文章Windows 回调监控 <一> 总结了关于CreateProcessNotify,CreateProcessNotifyEx和LoadImageNotify一些用法,之后产生 ...

  2. 李洪强iOS开发之添加手势

    李洪强iOS开发之添加手势 02 - 添加手势

  3. 李洪强iOS开发之后使用XIB实现横向滚动的UIScrollView

    李洪强iOS开发之后使用XIB实现横向滚动的UIScrollView 11111222

  4. android 矩阵处理类:Matrix

    在Android中,对图片的处理需要使用到Matrix类,Matrix是一个3 x 3的矩阵,他对图片的处理分为四个基本类型: 1.Translate 2.Scale 3.Rotate 4.Skew ...

  5. hadoop 1.2.1 eclipse 插件编译

    hadoop-1.2.1 eclipse插件编译       在ubuntu上进行hadoop相关的开发,需要在eclipse上安装hadoop开发插件.最新释放出的hadoop包含源码的包,以had ...

  6. docker基本概念,创建、起动实例,保存自定义镜像等常用操作

    14年docker火了一阵,当时自学整理了一份文档,后来冷落了. 现在发现很多同事还是想学习docker,但无从下手,所以重新整理了这篇分享,10分钟就可以带你彻底理解docker,并能够创建属于自己 ...

  7. 使用qmake生成Makefile

    Qmake自动生成Makefile 手动写Makefile是一件痛苦的事情,稍不小心就会出错,不过qmake可以让你脱离苦海 qmake可以根据你提供的.pro文件,生成Makefile不过他可比Ma ...

  8. 10位IT领袖给应届毕业生的10条忠告

    10位IT领袖给应届毕业生的10条忠告,在走向独立和自主的伟大征程中,吸取他们的经验. 在毕业生们迈出象牙塔之时,他们应该听从哪些人的建议?在走向独立和自主的伟大征程中,他们该吸取哪些教训?听一听各领 ...

  9. AES加密和解密

    using System; using System.Security.Cryptography; using System.Text; using System.IO; namespace AES ...

  10. 【coursera笔记】Machine Learning(Week6)

    发现自己不写总结真是件很恶劣的事情,好多学的东西没有自己总结都忘记了.所以决定从今天开始,学东西的时候一定跟上总结. 我写的东西大多数是自己通俗的总结,不太喜欢写严格的定义或者证明,写了也记不住,欢迎 ...