CF2193A.DBMB and the Array

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

DBMB had a birthday yesterday. He was gifted an array aa of nn elements and a number xx. But there is one problem: he only likes arrays where the sum of the elements equals ss. To make the array appealing to him, you can perform the following operation any number of times:

  • Choose an index ii (1≤i≤n1 \le i \le n) and add xx to the number aia_i.

For example, if he was given the array [1,2,3,5][1, 2, 3, 5] and x=2x = 2, you can choose index 33 and get the array [1,2,5,5][1, 2, 5, 5]. Your task is to determine whether the array can appeal to DBMB after any number of operations.

DBMB 昨天过生日了。他收到了一个包含 nn 个元素的数组 aa 和一个数 xx。但有一个问题:他只喜欢元素之和等于 ss 的数组。为了让该数组对他有吸引力,你可以执行以下操作任意多次:

  • 选择一个下标 ii(1≤i≤n1 \le i \le n),并将 xx 加到 aia_i 上。

例如,若他收到的数组为 [1,2,3,5][1, 2, 3, 5] 且 x=2x = 2,你可以选择下标 33,从而得到数组 [1,2,5,5][1, 2, 5, 5]。你的任务是判断:经过任意次数的操作后,该数组是否可能变得对 DBMB 有吸引力。

输入格式

Each test consists of several test cases. The first line contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases. The following describes the test cases.

The first line of each test case contains three integers nn, ss, xx (1≤n,x≤101 \le n, x \le 10, 1≤s≤1001 \le s \le 100).

The second line of each test case contains nn integers a1,a2,…ana_1, a_2, \dots a_n (1≤ai≤101 \le a_i \le 10) — the elements of the array gifted to DBMB.

每个测试包含若干测试用例。第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000),表示测试用例的数量。接下来描述各测试用例。

每个测试用例的第一行包含三个整数 nn、ss、xx(1≤n,x≤101 \le n, x \le 10,1≤s≤1001 \le s \le 100)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤101 \le a_i \le 10),表示赠予 DBMB 的数组元素。

输出格式

For each test case, output "YES" if the array can appeal to DBMB. Otherwise, output "NO".

You can output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

对于每个测试用例,如果该数组能够吸引 DBMB,则输出 “YES”;否则输出 “NO”。

你可以以任意大小写形式输出每个字母(小写或大写)。例如,字符串 “yEs”、“yes”、“Yes” 和 “YES” 均被视为有效的肯定回答。

输入输出样例

  • 输入#1

    6
    3 3 5
    1 1 1
    3 8 2
    1 2 3
    4 7 2
    1 1 1 1
    3 15 1
    2 4 10
    2 100 5
    4 6
    5 12 1
    1 2 2 3 2

    输出#1

    YES
    YES
    NO
    NO
    YES
    YES

说明/提示

In the second test case, a=[1,2,3]a = [1, 2, 3], applying the operation on a2a_2 gives us a=[1,4,3]a = [1, 4, 3]. The sum of the array equals ss.

在第二个测试用例中,a=[1,2,3]a = [1, 2, 3],对 a2a_2 执行操作后得到 a=[1,4,3]a = [1, 4, 3]。此时数组的和等于 ss。

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

首页