#C4386. Gift Box Permutations

    ID: 47918 Type: Default 1000ms 256MiB

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 NM, 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\).

## sample
1 1
1