Nyoj (simple math) Oh, my paper!

Source: Internet
Author: User

Oh, my paper! time limit: +Ms | Memory Limit:65535KB Difficulty:2
Describe
Give you a piece of paper, N (Row) *m (column) to calculate your are
Calculated from a diagonal line to another diagonal how many walk method (only upward or downward, left, and right away).
Input
The
input contains several testcases. Each are specified by and unsigned 32-bit integers n and m of the last Test case are followed by a line that contains both Zeroe S.
this line must not being Processe
Output
For the test case, output on a line, how
many paths can calculate
Sample input
2 31 10 0
Sample output
102
Tips
The num is a little big and you ' d better use unsigned
Source
Original
Uploaded by

Acm_ He Rongwei

Idea: (directly with Viagra) give you a piece of paper, N (Row) *m (column) you want to calculate the
Figure out how many moves from one diagonal to another (only up, right).
Analysis: A matrix, which has rows and columns, to reach the diagonal, there must be through all the rows and columns, then there are two cases, when the row (n) = = column (m), that is, just go through the columns and rows, in M+n to choose m or n combination of C (m+n,m) or C (m+n,n).
When the two are not equal, it is necessary to look at the first, all the smallest must arrive first.

#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, a, b;        A=n+m;        b=n<m?n:m;        Double sum=1;        while (b>0)            sum*= (a--/(double) (b--));        printf ("%.lf\n", sum);}    }


Nyoj (simple math) Oh, my paper!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.