#C6070. Unique Toy Packages

    ID: 49790 Type: Default 1000ms 256MiB

Unique Toy Packages

Unique Toy Packages

Bogo has a collection of toys labeled with integers. He wishes to create unique packages of toys such that each package contains exactly k distinct toy types. Given an array of n toy labels, determine the number of unique packages Bogo can form. In other words, let \( U \) be the set of unique toy labels from the input. If \(|U| < k\), it is impossible to form a package and the answer is \(0\). Otherwise, the answer is given by the combination formula:

[ C(|U|, k) = \frac{|U|!}{k! ; (|U|-k)!} ]

For example, if n = 5, k = 3 and the toy labels are [1, 2, 3, 4, 5], then the unique toys are 5 in number, and the total number of packages is \(C(5, 3) = 10\).

inputFormat

The input is given from standard input in the following format:

  1. The first line contains two integers n and k separated by a space.
  2. The second line contains n integers representing the toy labels.

It is guaranteed that n is a positive integer.

outputFormat

Print a single integer which is the number of unique packages that can be formed with exactly k distinct toys, as described. The output should be written to standard output.

## sample
5 3
1 2 3 4 5
10