6847.Distributing Apples

Time Limit: 1s Memory Limit: 512MB

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 Format(From the terminal/stdin)

The only input line has two integers $n$ and $m$ .

  • $1 \le n,m \le 10^6$

Output Format(To the terminal/stdout)

Print the number of ways modulo $10^9+7$ .

Sample Input

Copy
3 2
 · \n

Sample Output

Copy
6
 \n
Source: CSES, Mathematics, 1716

Submit

请先 登录

© 2025 FAQs