#C11026. Number of Ways to Prepare a Dish
Number of Ways to Prepare a Dish
Number of Ways to Prepare a Dish
You are given N distinct ingredients and you need to select exactly M ingredients in order to prepare a special dish. The number of ways to choose these ingredients is given by the binomial coefficient \(\binom{N}{M}\), which can be computed using the formula:
\[ \binom{N}{M} = \frac{N!}{M!(N-M)!} \pmod{10^9+7} \]
Your task is to compute \(\binom{N}{M}\) modulo \(10^9 + 7\). Although an array containing the ingredient values is provided as part of the input, the actual values are irrelevant; only the count matters.
inputFormat
The input is given via standard input and consists of:
- A first line with two space-separated integers
N
andM
, whereN
is the total number of ingredients, andM
is the number of ingredients to choose. - A second line containing
N
space-separated integers representing the ingredients (these values are not used in the computation).
outputFormat
The output should be a single integer representing the number of ways to choose M
ingredients out of N
(i.e. \(\binom{N}{M}\)) computed modulo \(10^9+7\). The result should be printed to standard output.
5 3
1 2 3 4 5
10