← All problemsSign in

Distributing Apples

CSESMathematicsOpen on judge ↗

There are n children and m apples that will be distributed to them. Your task is to count the number of ways this can be done. For example, if n=3 and m=2, there are 6 ways: [0,0,2], [0,1,1], [0,2,0], [1,0,1], [1,1,0] and [2,0,0]. Input The only input line has two integers n and m. Output Print the number of ways modulo 10^9+7. Constraints - 1 \le n,m \le 10^6 Example Input: 3 2 Output:

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start