Redaksiya
The required path is a broken line consisting of links. Of these, links must be vertical, and the rest must be horizontal. The number of ways to choose vertical links out of is equal to .
Example
For the first test case . The answer is .
For the second test case . The answer is .
Algorithm realization
The function Cnk computes the value of the binomial coefficient .
long long Cnk(long long n, long long k) { long long res = 1; if (k > n - k) k = n - k; for (long long i = 1; i <= k; i++) res = res * (n - i + 1) / i; return res; }
The main part of the program. Read the input data.
scanf("%lld %lld", &n, &m);
Compute and print the answer .
res = Cnk(n + m, n); printf("%lld\n", res);
Python realization
import math
Read the input data.
n, m = map(int,input().split())
Compute and print the answer .
res = math.comb(n + m, n) print(res)