CF2193A.DBMB and the Array
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
DBMB had a birthday yesterday. He was gifted an array a of n elements and a number x. But there is one problem: he only likes arrays where the sum of the elements equals s. To make the array appealing to him, you can perform the following operation any number of times:
- Choose an index i (1≤i≤n) and add x to the number ai.
For example, if he was given the array [1,2,3,5] and x=2, you can choose index 3 and get the array [1,2,5,5]. Your task is to determine whether the array can appeal to DBMB after any number of operations.
DBMB 昨天过生日了。他收到了一个包含 n 个元素的数组 a 和一个数 x。但有一个问题:他只喜欢元素之和等于 s 的数组。为了让该数组对他有吸引力,你可以执行以下操作任意多次:
- 选择一个下标 i(1≤i≤n),并将 x 加到 ai 上。
例如,若他收到的数组为 [1,2,3,5] 且 x=2,你可以选择下标 3,从而得到数组 [1,2,5,5]。你的任务是判断:经过任意次数的操作后,该数组是否可能变得对 DBMB 有吸引力。
输入格式
Each test consists of several test cases. The first line contains a single integer t (1≤t≤1000) — the number of test cases. The following describes the test cases.
The first line of each test case contains three integers n, s, x (1≤n,x≤10, 1≤s≤100).
The second line of each test case contains n integers a1,a2,…an (1≤ai≤10) — the elements of the array gifted to DBMB.
每个测试包含若干测试用例。第一行包含一个整数 t(1≤t≤1000),表示测试用例的数量。接下来描述各测试用例。
每个测试用例的第一行包含三个整数 n、s、x(1≤n,x≤10,1≤s≤100)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤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], applying the operation on a2 gives us a=[1,4,3]. The sum of the array equals s.
在第二个测试用例中,a=[1,2,3],对 a2 执行操作后得到 a=[1,4,3]。此时数组的和等于 s。
输入解题思路,AI测评打分。不知道怎么写?