Time Limit: 1000MS | Memory Limit: 30000K | |
Total Submissions: 21503 | Accepted: 5284 |
Description
Fortunately you have a piece of squared paper and you choose a rectangle of size n*m on the paper. Let's call this rectangle together with the lines it contains a grid. Starting at the lower left corner of the grid, you move your pencil to the upper right corner, taking care that it stays on the lines and moves only to the right or up. The result is shown on the left:
Really a masterpiece, isn't it? Repeating the procedure one more time, you arrive with the picture shown on the right. Now you wonder: how many different works of art can you produce?
Input
Output
Sample Input
5 4 1 1 0 0
Sample Output
126 2
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#define MOD 1000000009
using namespace std;
int main()
{
long long n,m,c;
while(scanf("%I64d %I64d",&n,&m)&&(n||m))
{
c=1;
for(long long i=1;i<=min(n,m);i++)
{
c=c*(m+n-i+1)/i;
}
printf("%I64d\n",c);
}
return 0;
}