A supply run must split n identical ration packs among k outposts arranged in a fixed order. Every outpost must receive at least one pack. Count the number of ways to assign the packs; two assignments differ if some outpost receives a different number of packs. If it is impossible (more outposts than packs), the answer is 0. Report the count modulo 1000000007.
A single line with two integers n and k.
A single integer: the number of valid assignments, modulo 1000000007.
Example 1
Input
5 2
Expected
4
Explanation
Split 5 packs into 2 positive parts: (1,4),(2,3),(3,2),(4,1) = 4 = C(4,1).
Example 2
Input
4 4
Expected
1
Explanation
Four packs among four outposts, each at least one, forces (1,1,1,1): exactly 1 way.
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 →