C1754 [CCPC2017秦皇岛站-H] Prime Set

内存限制:256 MB 时间限制:1000 ms

题目描述

Given an array of $n$ integers $a_1,a_2,...,a_n$, we say a set $\{i,j\}$ is a prime set of the given array, if $i \ne j$ and $a_i+a_j$ is prime.

BaoBao has just found an array of $n$ integers $a_1,a_2,...,a_n$ in his pocket. He would like to select at most $k$ prime set of that array to maximize the size of the union of the selected sets.

That is to say, to maximize $|\bigcup\limits_{i=1}^m p_i|$ by carefully selecting $m$ and $p_1, p_2, ..., p_m$, where $m \le k$ and $p_i$ is a prime set of the given array. Please help BaoBao calculate the maximum size of the union set.

输入格式

There are multiple test cases. The first line of the input is an integer $T$, indicating the number of test cases. For each test case:

The first line contains two integers $n$ and $k(1 \le n \le 3 \times 10^3, 0 \le k \le \frac{n(n-1)}{2})$, their meanings are described above.

The second line contains $n$ integers $a_1, a_2, ..., a_n(1 \le a_i \le 10^6)$ , indicating the given array.

It's guaranteed that the sum of $n$ over all test cases will not exceed $10^4$.

输出

For each test case output one line containing one integer, indicating the maximum size of the union of at most $k$ prime set of the given array.

样例

样例输入 1

4 4 2 2 3 4 5 5 3 3 4 12 3 6 6 3 1 3 6 8 1 1 1 0 1

样例输出 1

4 3 6 0

提示