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 numbers , and a non-zero number .
You need to perform operations. In each operation, you need to choose an index (), and then add to .
You must ensure that after each operation, the new value of is not .
Determine whether you can complete these operations.
Input Format
This problem has multiple test cases.
The first line contains a positive integer , the number of test cases. For each test case:
- The first line contains two integers .
- The second line contains integers .
Output Format
For each test case, output one string per line. If you can perform 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 , where , but , so you cannot perform the operation. Output No.
For the second test case, you can alternate between choosing index and index . Then will keep changing by and , so it will always vary between and . 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): .
- Test point 2 (50 points): no special restrictions.
For all test points: , , .
Translated by ChatGPT 5