#C8063. Count Genres with Minimum Books
Count Genres with Minimum Books
Count Genres with Minimum Books
You are given a collection of books, where each book is classified into a genre represented by an integer. For each test case, you are provided with:
- An integer n denoting the number of books.
- An integer k which is the minimum number of books that a genre must have to be counted.
- A list of n integers where each integer represents the genre of a book.
Your task is to determine the number of distinct genres that have at least \( k \) books. Formally, for each test case, if a genre appears at least \( k \) times among the n books, it is counted.
Input/Output Requirements: The program should read from standard input (stdin) and output the results to standard output (stdout). In the input, the first value indicates the number of test cases t. This is followed by the descriptions for each test case.
Example in LaTeX:
Given a test case where
\( n = 10 \), \( k = 2 \), and the list of genres is \([1, 2, 2, 3, 3, 3, 4, 4, 4, 4]\), the answer is \( 3 \) because genres 2, 3, and 4 appear at least 2 times.
inputFormat
The first line of input contains an integer t denoting the number of test cases. Each test case is described as follows:
- The first line of each test case contains two integers, n and k, where n is the number of books and k is the threshold number of books required for a genre to be counted.
- The second line contains n space-separated integers representing the genres of the books.
All input should be read from standard input (stdin).
outputFormat
For each test case, output a single integer on a new line representing the count of genres that have at least k books.
All output should be written to standard output (stdout).
## sample1
10 2
1 2 2 3 3 3 4 4 4 4
3
</p>