~/algor $ cat problems/kombinatorika-jamoa-tuzish
Forming a team
Medium
1000 ms
128 MB
49%
A class has $n$ boys and $m$ girls. A team of exactly $k$ people must be formed from them, with at least $g$ girls in it. The order of the team members does not matter. How many ways are there? Print the answer modulo $10^{9} + 7$.
Input
One line with four integers: $n$, $m$, $k$ and $g$.
Output
One integer — the number of ways modulo $10^{9} + 7$.
Note
$0 \le n, m \le 10^{6}$
$1 \le k \le \max(1, n + m)$
$0 \le g \le k$
Examples
Input #1
4 3 3 2
Output #1
13
Input #2
2 1 3 2
Output #2
0