CF1475E.Advertising Agency

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Masha works in an advertising agency. In order to promote the new brand, she wants to conclude contracts with some bloggers. In total, Masha has connections of nn different bloggers. Blogger numbered ii has aia_i followers.

Since Masha has a limited budget, she can only sign a contract with kk different bloggers. Of course, Masha wants her ad to be seen by as many people as possible. Therefore, she must hire bloggers with the maximum total number of followers.

Help her, find the number of ways to select kk bloggers so that the total number of their followers is maximum possible. Two ways are considered different if there is at least one blogger in the first way, which is not in the second way. Masha believes that all bloggers have different followers (that is, there is no follower who would follow two different bloggers).

For example, if n=4n=4 , k=3k=3 , a=[1,3,1,2]a=[1, 3, 1, 2] , then Masha has two ways to select 33 bloggers with the maximum total number of followers:

  • conclude contracts with bloggers with numbers 11 , 22 and 44 . In this case, the number of followers will be equal to a1+a2+a4=6a_1 + a_2 + a_4 = 6 .
  • conclude contracts with bloggers with numbers 22 , 33 and 44 . In this case, the number of followers will be equal to a2+a3+a4=6a_2 + a_3 + a_4 = 6 .

Since the answer can be quite large, output it modulo 109+710^9+7 .

输入格式

The first line contains one integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then tt test cases follow.

The first line of each test case contains two integers nn and kk ( 1kn10001 \le k \le n \le 1000 ) — the number of bloggers and how many of them you can sign a contract with.

The second line of each test case contains nn integers a1,a2,ana_1, a_2, \ldots a_n ( 1ain1 \le a_i \le n ) — the number of followers of each blogger.

It is guaranteed that the sum of nn over all test cases does not exceed 10001000 .

输出格式

For each test case, on a separate line output one integer — the number of ways to select kk bloggers so that the total number of their followers is maximum possible.

输入输出样例

  • 输入#1

    3
    4 3
    1 3 1 2
    4 2
    1 1 1 1
    2 1
    1 2

    输出#1

    2
    6
    1

说明/提示

The test case is explained in the statements.

In the second test case, the following ways are valid:

  • conclude contracts with bloggers with numbers 11 and 22 . In this case, the number of followers will be equal to a1+a2=2a_1 + a_2 = 2 ;
  • conclude contracts with bloggers with numbers 11 and 33 . In this case, the number of followers will be equal to a1+a3=2a_1 + a_3 = 2 ;
  • conclude contracts with bloggers with numbers 11 and 44 . In this case, the number of followers will be equal to a1+a4=2a_1 + a_4 = 2 ;
  • conclude contracts with bloggers with numbers 22 and 33 . In this case, the number of followers will be equal to a2+a3=2a_2 + a_3 = 2 ;
  • conclude contracts with bloggers with numbers 22 and 44 . In this case, the number of followers will be equal to a2+a4=2a_2 + a_4 = 2 ;
  • conclude contracts with bloggers with numbers 33 and 44 . In this case, the number of followers will be equal to a3+a4=2a_3 + a_4 = 2 .

In the third test case, the following ways are valid:

  • concludes a contract with a blogger with the number 22 . In this case, the number of followers will be equal to a2=2a_2 = 2 .
首页