#K50227. Counting Distinct Flower Bouquets
Counting Distinct Flower Bouquets
Counting Distinct Flower Bouquets
You are given two integers \(N\) and \(K\) representing the number of available flower types and the number of flowers to be used in a bouquet respectively. A valid bouquet is one in which each flower is of a distinct type (i.e. no two adjacent flowers are of the same type, which in this problem is ensured by selecting different flowers for each position). In other words, you are required to form a bouquet by selecting exactly \(K\) distinct flowers from \(N\) available types.
If \(K > N\), it is impossible to choose \(K\) distinct flowers, and the answer will be 0. Otherwise, the answer is equal to the permutation count:
[ P(N, K) = N \times (N-1) \times \cdots \times (N-K+1), \mod, (10^9+7) ]
Your task is to compute this value.
inputFormat
The input consists of a single line with two space-separated integers: \(N\) and \(K\).
outputFormat
Output a single integer representing the number of valid bouquets modulo \(10^9+7\).
## sample3 3
6