// 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. 安装DirectX SDK (June 2010) 失败(Error Code S1023)(转)

    解决: 在控制面板里面搜索“Microsoft Visual C++*”,然后卸载,这个工具的名字大概是: Microsoft Visual C++ 2010 x86/x64 redistribuab ...

  2. JSON.stringify 函数 (JavaScript)

    在bsrck项目中,使用jQuery.Form.js的ajaxSubmit时,遇到有文件上传的form提交,在firefox和chrome浏览器中测试,报Bad Request的错误,经查代码后发现是 ...

  3. 8天学通MongoDB——第三天 细说高级操作

    原文地址:http://www.cnblogs.com/huangxincheng/archive/2012/02/21/2361205.html 今天跟大家分享一下mongodb中比较好玩的知识,主 ...

  4. 欧拉工程第51题:Prime digit replacements

    题目链接 题目: 通过置换*3的第一位得到的9个数中,有六个是质数:13,23,43,53,73和83. 通过用同样的数字置换56**3的第三位和第四位,这个五位数是第一个能够得到七个质数的数字,得到 ...

  5. Markdown语法和MWeb使用说明

    Markdown 语法和 MWeb 写作使用说明 开始写博客,首先熟悉一下Markdown,以前过看GitHub里的README.MD,感受到了这种文字排版的简洁美观. 写博客是一种有效的学习总结和分 ...

  6. 305. Number of Islands II

    题目: A 2d grid map of m rows and n columns is initially filled with water. We may perform an addLand  ...

  7. Data Flow ->> Term Extraction

    中文意思是关键词抽取,用于计算在文本中哪些词汇或者词组出现的频率最高.其实算法有两张:1)Frequency 2)TFIDF TFIDF的全称是Term Frequency and Inverse D ...

  8. PHP的面向对象编程

    面向对象编程的概念: 不同的作者之间说法可能不一样,但是一个OOP语言必须有以下几方面: 抽象数据类型和信息封装 继承 多态 在PHP中是通过类来完成封装的: <?php class Somet ...

  9. nova读取配置文件流程

          在我们安装nova的过程中,设置它的配置文件/etc/nova/nova.conf是必不可少的一步.配置好nova.conf文件,nova-compute.nova-network等服务才 ...

  10. Toast.makeText().show() 正常使用但不显示的解决办法

    症状: toast正常构造,调用show时,不显示. View tabMeItem = tabHost.findViewById(R.id.tab_me_xc); tabMeItem.setOnCli ...