nCr Mod P

EASY · C · 2000ms

Next: compute "N choose R" modulo the same prime, for use in a binomial-probability example. Read N and R. Print C(N,R) mod (10^9+7) using precomputed factorials and modular inverse (Fermat's little theorem), not Pascal's triangle, since N can be large.

Input

Two integers N R.

Output

C(N,R) mod (10^9+7).

Constraints

0 ≤ R ≤ N ≤ 10^6

Sample Input

5 2

Sample Output

10
main.c
Loading editor…

Write C, then Run (custom I/O) or Submit (sample tests). ⌘/Ctrl+Enter submits.

nCr Mod P · DIU ContestHub