#C6761. Aesthetically Pleasing Recipes
Aesthetically Pleasing Recipes
Aesthetically Pleasing Recipes
You are given n distinct ingredients, and you need to create a recipe of length m using these ingredients. A recipe is considered aesthetically pleasing if all ingredients are distinct (i.e., no ingredient is repeated).
Your task is to count the number of such recipes. This is equivalent to counting the number of ways to choose and order m distinct ingredients from n available ones. Mathematically, the number of possible recipes is given by the permutation formula:
$$P(n,m)=\frac{n!}{(n-m)!}$$
Since this number can be very large, output the result modulo $$10^9+7$$.
inputFormat
The input consists of a single line containing two space-separated integers n and m:
- n: the total number of distinct ingredients.
- m: the length of the recipe.
If m > n, no recipe is possible, so output 0.
outputFormat
Output a single integer representing the number of aesthetically pleasing recipes modulo $$10^9+7$$.
## sample3 2
6