luogu#P8550. 冬之花

冬之花

Background

“Crying is not because of sadness,

but simply because you are alive, tears will come out without you noticing.”

After Hilde broke up, she went to the main road to race. Because she was racing, she did not want to stay on the road all the time, so she drove in circles on the yellow sand fields on both sides of the road. The steering of her cheap car had some problems, but she really wanted to drive in circles.

Problem Description

Given nn numbers a1,a2,,ana_1, a_2, \ldots, a_n, and a non-zero number xx.

You need to perform 10100{10}^{100} operations. In each operation, you need to choose an index ii (1in1 \le i \le n), and then add aia_i to xx.

You must ensure that after each operation, the new value of xx is not 00.

Determine whether you can complete these 10100{10}^{100} operations.

Input Format

This problem has multiple test cases.

The first line contains a positive integer TT, the number of test cases. For each test case:

  • The first line contains two integers n,xn, x.
  • The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n.

Output Format

For each test case, output one string per line. If you can perform 10100{10}^{100} operations, output Yes, otherwise output No.

2
1 1
-1
2 10
1 -1

No
Yes

Hint

[Sample Explanation]

For the first test case, in the first operation you can only choose index 11, where a1=1a_1=-1, but 1+(1)=01+(-1)=0, so you cannot perform the operation. Output No.

For the second test case, you can alternate between choosing index 11 and index 22. Then xx will keep changing by +1+1 and 1-1, so it will always vary between 1010 and 99. In this way, you can perform any number of operations. Output Yes. Of course, this is only one possible plan, and you may have other plans.


[Constraints]

  • Test point 1 (50 points): n=1n = 1.
  • Test point 2 (50 points): no special restrictions.

For all test points: 1T301 \le T \le 30, 1n51 \le n \le 5, 1x,ai1001 \le \lvert x \rvert, \lvert a_i \rvert \le 100.

Translated by ChatGPT 5