A community lottery forms a committee by choosing a group of members from a pool of applicants. Given the pool size n and the committee size r, count how many distinct committees of exactly r members can be formed. The order in which members are picked does not matter, and no member may appear twice. Because the count can be enormous, report it modulo 1000000007.
A single line with two integers n and r.
A single integer: the number of distinct committees, modulo 1000000007.
Example 1
Input
5 2
Expected
10
Explanation
Choosing 2 members from 5 gives C(5,2)=10 committees.
Example 2
Input
6 0
Expected
1
Explanation
There is exactly one way to choose an empty committee, so the answer is 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →