Help her, track down the number of ways of choosing k bloggers with the goal that the absolute number of their devotees is greatest conceivable. Two different ways are considered unique in case there is no less than one blogger in the primary manner, which isn't in the subsequent manner. Masha accepts that all bloggers have various adherents (that is, there is no devotee who might follow two distinct bloggers).
Correct answer will be upvoted else downvoted. Computer science.
Help her, track down the number of ways of choosing k bloggers with the goal that the absolute number of their devotees is greatest conceivable. Two different ways are considered unique in case there is no less than one blogger in the primary manner, which isn't in the subsequent manner. Masha accepts that all bloggers have various adherents (that is, there is no devotee who might follow two distinct bloggers).
For instance, assuming n=4, k=3, a=[1,3,1,2], Masha has two different ways to choose 3 bloggers with the greatest all out number of supporters:
finish up agreements with bloggers with numbers 1, 2 and 4. For this situation, the number of devotees will be equivalent to a1+a2+a4=6.
finish up agreements with bloggers with numbers 2, 3 and 4. For this situation, the number of adherents will be equivalent to a2+a3+a4=6.
Since the appropriate response can be very huge, output it modulo 109+7.
Input
The main line contains one integer t (1≤t≤1000) — the number of experiments. Then, at that point, t experiments follow.
The primary line of each experiment contains two integers n and k (1≤k≤n≤1000) — the number of bloggers and the number of them you can sign an agreement with.
The second line of each experiment contains n integers a1,a2,… an (1≤
It is ensured that the amount of n over all experiments doesn't surpass 1000.
Output
For each experiment, on a different line output one integer — the number of ways of choosing k bloggers with the goal that the all out number of their devotees is greatest conceivable
Step by step
Solved in 4 steps with 1 images