#C2662. Basket Combination Count

    ID: 46003 Type: Default 1000ms 256MiB

Basket Combination Count

Basket Combination Count

You are given a basket combination problem. There are M types of items available and a basket must contain exactly N items. Although the quantities for each item type are provided as an array, each basket can contain at most one item of a given type. In other words, if an item type has a nonzero quantity then it is eligible to be chosen. The task is to calculate the number of ways to choose exactly N item types from the M available types. This number is given by the binomial coefficient \(\binom{M}{N}\) (i.e. "M choose N").

Input: The first line contains an integer representing the number of test cases. For each test case, the first line contains two integers M and N, and the next line contains M integers representing the quantities of each item type.

Output: For each test case, output the value of \(\binom{M}{N}\) on a new line.

Note: Even though a list of quantities is provided, every quantity is at least 1, so the solution only involves computing the binomial coefficient.

inputFormat

The input begins with an integer T, the number of test cases. Each test case consists of two lines:

  • The first line contains two integers M and N separated by a space.
  • The second line contains M integers separated by spaces, which are the quantities of each type of item (each quantity is at least 1).

It is guaranteed that 0 ≤ N ≤ M.

outputFormat

For each test case, output a single line containing the number of ways to choose exactly N item types from the M available types. This number is \(\binom{M}{N}\).

## sample
3
3 2
1 2 3
4 3
2 2 1 1
5 3
1 1 1 1 1
3

4 10

</p>