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!