#C4386. Gift Box Permutations
Gift Box Permutations
Gift Box Permutations
You are given two integers N and M. You need to determine the number of distinct permutations of chocolates possible to create a gift box containing exactly N chocolates using M available types. In other words, if you choose N distinct chocolate types out of M (where order matters), compute the number of such ordered arrangements.
Mathematically, if N ≤ M, the answer is given by the permutation formula:
\(P(M,N)=\frac{M!}{(M-N)!}\)
Since the numbers can be large, output the result modulo \(10^9+7\). If N > M, it is impossible to select N different chocolate types from M types, so the answer is 0.
Example:
- Input: 3 5
Output: 60 - Input: 4 3
Output: 0
inputFormat
The input is given from the standard input in a single line containing two space‐separated integers N and M.
Constraints:
- N and M are positive integers.
outputFormat
Output a single integer which is the number of distinct permutations modulo \(10^9+7\).
## sample1 1
1