#P16792. [蓝桥杯 2026 国 A] 不互质游戏
[蓝桥杯 2026 国 A] 不互质游戏
Problem Description
Xiaolan and his friend Xiaoqiao are playing a game about positive integers.
At the beginning, there are positive integers on the table. Xiaolan moves first, and the two players take turns.
In one move, a player needs to choose a number currently on the table and change it to a smaller positive integer . This change is legal if and only if and and are not coprime.
“Not coprime” means the greatest common divisor of the two positive integers is greater than , i.e. . For example, for the number , it can be changed to ; for the number , it can be changed to . The number and all prime numbers cannot be changed, because there is no smaller positive integer that satisfies the conditions.
When it is a player’s turn, if they cannot make any legal move, then that player loses the game.
It is known that both Xiaolan and Xiaoqiao will use optimal strategies. Now determine whether Xiaolan has a winning strategy for the given initial position.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , representing the number of test cases.
Then test cases follow. Each test case consists of two lines:
- The first line contains a positive integer , representing the number of initial numbers.
- The second line contains positive integers , representing the initial position of the game.
Output Format
For each test case, output one line.
If Xiaolan must win, output Yes; otherwise output No.
2
3
1 3 100
2
100000 100000
Yes
No
Hint
Sample Explanation
For the first test case, Xiaolan can change to . After that, can no longer be legally changed. Xiaoqiao has no legal move, so Xiaolan must win.
For the second test case, the two numbers are the same. No matter how Xiaolan changes one of them, Xiaoqiao can make the same change to the other one. In the end, Xiaolan will face a position with no legal moves, so Xiaoqiao must win.
Constraints
For of the test cases, , .
For of the test cases, , .
For all test cases, , , , and the sum of over all test cases does not exceed .
Translated by ChatGPT 5