nyoj(简单数学)Oh, my Paper!
来源:互联网 发布:软件开发社区 编辑:程序博客网 时间:2024/04/29 19:26
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 31 10 0
- 样例输出
102
- 提示
- 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
- nyoj(简单数学)Oh, my Paper!
- NYOJ 635 Oh, my goddess (简单BFS)
- nyoj--635--Oh, my goddess(dfs)
- nyoj 635 Oh, my goddess 【bfs(简单题)】
- NYOJ 635 Oh, my goddess
- NYOJ 635 Oh, my goddess (BFS + 优先队列)
- oh my zsh 简单使用
- NYOJ-635 Oh, my goddess C语言
- Oh, my goddess(bfs)
- NYOJ 635-Oh, my goddess【bfs+优先队列】
- NYOJ - 635 - Oh, my goddess(BFS,优先队列)
- nyoj 635 Oh, my goddess 优先队列+BFS
- Oh, my goddess(优先队列)
- Linux 安装 oh my zsh 终端及简单使用方法
- 超简单配置你的 oh my zsh
- OH! My leg
- oH mY BLAck...
- oh, my god
- 最大公约数
- 配置jdk
- 图解MongoDB原理
- Linux 驱动模型初探1——BUS
- Stanford机器学习---第一讲. Linear Regression with one variable
- nyoj(简单数学)Oh, my Paper!
- 反射的一些性质
- Linux下UDP的连接程序示例(阻塞、非阻塞)
- 我的常用的指令
- GCC摘记
- iPhone开发之NSLog使用技巧
- 三星s5开发者选项不能连电脑问题
- Android 从硬件到应用:一步一步向上爬 1 -- 从零编写底层硬件驱动程序
- net-snmp代理开发——自定义table实现