CF1477A.Nezzar and Board

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

nn distinct integers x1,x2,…,xnx_1,x_2,\ldots,x_n are written on the board. Nezzar can perform the following operation multiple times.

  • Select two integers x,yx,y (not necessarily distinct) on the board, and write down 2x−y2x-y. Note that you don't remove selected numbers.

Now, Nezzar wonders if it is possible to have his favorite number kk on the board after applying above operation multiple times.

黑板上写着 nn 个互不相同的整数 x1,x2,…,xnx_1,x_2,\ldots,x_n。Nezzar 可以多次执行以下操作:

  • 从黑板上选出两个整数 x,yx,y(二者可以相同),并将 2x−y2x-y 写在黑板上。注意:被选中的数不会被移除。

现在,Nezzar 想知道:经过若干次上述操作后,能否使他最喜爱的数 kk 出现在黑板上?

输入格式

The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5) — the number of test cases.

The first line of each test case contains two integers n,kn,k (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5, −1018≤k≤1018-10^{18} \le k \le 10^{18}).

The second line of each test case contains nn distinct integers x1,x2,…,xnx_1,x_2,\ldots,x_n (−1018≤xi≤1018-10^{18} \le x_i \le 10^{18}).

It is guaranteed that the sum of nn for all test cases does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 tt(1≤t≤1051 \le t \le 10^5)—— 测试用例的数量。

每个测试用例的第一行包含两个整数 n,kn,k(2≤n≤2⋅1052 \le n \le 2 \cdot 10^5,−1018≤k≤1018-10^{18} \le k \le 10^{18})。

每个测试用例的第二行包含 nn 个互不相同的整数 x1,x2,…,xnx_1,x_2,\ldots,x_n(−1018≤xi≤1018-10^{18} \le x_i \le 10^{18})。

保证所有测试用例的 nn 之和不超过 2⋅1052 \cdot 10^5。

输出格式

For each test case, print "YES" on a single line if it is possible to have kk on the board. Otherwise, print "NO".

You can print each letter in any case (upper or lower).

对于每个测试用例,如果可以在黑板上得到数字 kk,则在单独一行输出 "YES";否则输出 "NO"。

你可以以任意大小写(大写或小写)输出每个字母。

输入输出样例

  • 输入#1

    6
    2 1
    1 2
    3 0
    2 3 7
    2 -1
    31415926 27182818
    2 1000000000000000000
    1 1000000000000000000
    2 -1000000000000000000
    -1000000000000000000 123
    6 80
    -5 -20 13 -14 -2 -11

    输出#1

    YES
    YES
    NO
    YES
    YES
    NO

说明/提示

In the first test case, the number 11 is already on the board.

In the second test case, Nezzar could perform the following operations to write down k=0k=0 on the board:

  • Select x=3x=3 and y=2y=2 and write down 44 on the board.
  • Select x=4x=4 and y=7y=7 and write down 11 on the board.
  • Select x=1x=1 and y=2y=2 and write down 00 on the board.

In the third test case, it is impossible to have the number k=−1k = -1 on the board.

在第一个测试用例中,数字 11 已经在黑板上。

在第二个测试用例中,Nezzar 可以执行以下操作,将 k=0k=0 写到黑板上:

  • 选择 x=3x=3 和 y=2y=2,并在黑板上写下 44。
  • 选择 x=4x=4 和 y=7y=7,并在黑板上写下 11。
  • 选择 x=1x=1 和 y=2y=2,并在黑板上写下 00。

在第三个测试用例中,无法在黑板上得到数字 k=−1k = -1。

输入解题思路,AI测评打分。不知道怎么写?

首页