The binomial coefficient or choose function is the number of ways to choose objects from objects. Its formula is well known: where . This formula is not very useful from a computational point of view, because we have to deal with huge numbers (the factorial numbers) to obtain much smaller results. For instance,
Despite the fact that the final number has only 6 digits, we need to
compute
,
which has 19 digits. This can be a problem because the type
int of 32 bits cannot store numbers with more than 10
digits.
However, this is not the only way to compute . For instance, binomial coefficients satisfy the following property: This recursive formula allow us to compute binomial coefficients with no multiplications nor divisions, by using a procedure known nowadays as “Pascal’s triangle” or “Tartaglia’s triangle”, although it has historical references more than 1000 years old:
| … |
| … |
To compute more binomial coefficients, you only have to fill more rows of the triangle. Use this idea to compute the value of several binomial coefficients.
Input consists of several cases, each with two natural numbers and , where and .
For each case, print .
Input
0 0 1 0 1 1 2 0 2 1 2 2
Output
1 1 1 1 2 1
Input
20 10 30 15 30 10 30 20 30 0 30 30
Output
184756 155117520 30045015 30045015 1 1