CF2078A.Final Verdict

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Final Verdict

Testify - void (Mournfinale) feat. 星熊南巫

You are given an array aa of length nn, and must perform the following operation until the length of aa becomes 11.

Choose a positive integer k<ak \lt |a| such that ak\frac{|a|}{k} is an integer. Split aa into kk subsequences^{\text{∗}} s1,s2,,sks_1, s_2, \ldots, s_k such that:

  • Each element of aa belongs to exactly one subsequence.
  • The length of every subsequence is equal.

After this, replace $a = \left[ \operatorname{avg}(s_1), \operatorname{avg}(s_2), \ldots, \operatorname{avg}(s_k) \right]$, where $\operatorname{avg}(s) = \frac{ um_{i = 1}^{|s|} s_i}{|s|}$ is the average of all the values in the subsequence. For example, $\operatorname{avg}([1, 2, 1, 1]) = \frac{5}{4} = 1.25$.

Your task is to determine whether there exists a sequence of operations such that after all operations, a=[x]a = [x].

^{\text{∗}}A sequence xx is a subsequence of a sequence yy if xx can be obtained from yy by the deletion of several (possibly, zero or all) elements.

Input

Each test contains multiple test cases. The first line contains the number of test cases tt (1t5001 \le t \le 500). The description of the test cases follows.

The first line of each test case contains two integers nn, xx (1n,x1001 \leq n, x \leq 100) — the length of the array aa and the final desired value.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1001 \leq a_i \leq 100) — the array aa.

Output

For each test case, output "YES'" (without quotes) if there exists such a sequence of operations, and "NO" (without quotes) otherwise.

You can output "YES" and "NO" in any case (for example, strings "yES", "yes" and "Yes" will be recognized as a positive response).

Note

In the first test case, x=3x = 3 and a=[3]a = [3] already holds.

In the second test case, x=9x = 9, and there exists no sequence of operations such that after all operations, a=[9]a = [9].

In the third test case, x=9x = 9, and here is one possible sequence of operations.

  1. k=2k = 2, s1=[1,12,8]s_1 = [1, 12, 8] and s2=[9,14,10]s_2 = [9, 14, 10]. Hence, $a = [\operatorname{avg}(s_1), \operatorname{avg}(s_2)] = [7, 11]$.
  2. k=1k = 1 and s1=[7,11]s_1 = [7, 11]. Hence, a=[avg(s1)]=[9]a = [\operatorname{avg}(s_1)] = [9].

In the fourth test case, x=10x = 10, and here is one possible sequence of operations.

  1. k=1k = 1 and s1=[10,10,10,10,10,10,10,10,10,10]s_1 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]. Hence, a=[avg(s1)]=[10]a = [\operatorname{avg}(s_1)] = [10].

Samples

4
1 3
3
4 9
7 11 2 5
6 9
1 9 14 12 10 8
10 10
10 10 10 10 10 10 10 10 10 10
YES
NO
YES
YES

在线编程 IDE

建议全屏模式获得最佳体验