nyoj(简单数学)Oh, my Paper!

Oh, my Paper!

时间限制: 1000 ms  |  内存限制: 65535 KB
难度: 2
描述
Give you a piece of paper, n (row) *m (column) to calculate your is
Calculated from a diagonal line to another diagonal how many walk method (only upward or downward, left, and right away).
输入
The input contains several testcases. Each is specified by two unsigned 32-bit integers n and m The last test case is followed by a line that contains two zeroes. This line must not be processe
输出
For each test case output on a line that how many paths you can calculate
样例输入
2 3
1 1
0 0
样例输出
10
2
提示
the num is a little big ,you'd better use unsigned
来源
原创
上传者

ACM_贺荣伟

思路:(直接用伟哥的)给你一张纸,n(行)*m(列)你要计算的是
算出从一个对角线到另一个对角线有多少走法(只能向上,向右走)。
分析:一个矩阵,它有行有列,要到达对角线,必定有通过所有的行和列,那么存在两种情况,当行(n)==列(m),即刚好走完列和行,在m+n个里选m或n个组合得C(m+n,m)或C(m+n,n)。
当两者不相等,就要看那个先到,所有最小的必定先到达。

#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
    long long n,m;
    while(~scanf("%lld%lld",&n,&m),n||m)
    {
        long long a,b;
        a=n+m;
        b=n<m?n:m;
        double sum=1;
        while(b>0)
            sum*=(a--/(double)(b--));
        printf("%.lf\n",sum);
    }
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值