luogu#P8178. 「EZEC-11」Sequence
「EZEC-11」Sequence
Problem Description
Given a sequence that satisfies .
Determine whether there exists a non-negative integer such that for all , is a multiple of the prime .
Input Format
This problem contains multiple test cases.
The first line contains an integer , indicating the number of test cases.
For each test case:
- The first line contains an integer .
- The second line contains integers .
- The third line contains integers .
- The fourth line contains integers , and it is guaranteed that is prime.
Output Format
For each test case:
- Output one string per line. If there exists an that satisfies the conditions, output
Yes; otherwise, outputNo.
2
3
1 1 1
2 2 2
3 5 7
3
1 1 1
2 2 2
3 3 3
Yes
No
Hint
[Sample 1 Explanation]
For the first test case, one feasible solution is . In this case, .
For the second test case, there is no that satisfies the conditions.
[Constraints and Notes]
This problem uses bundled tests.
- Subtask 1 (10 points): .
- Subtask 2 (20 points): .
- Subtask 3 (20 points): , .
- Subtask 4 (50 points): no special constraints.
For of the testdata: , , , , and is prime.
Translated by ChatGPT 5