#P16792. [蓝桥杯 2026 国 A] 不互质游戏

    ID: 19133 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>数学博弈论数论2026蓝桥杯国赛SG 函数bitset

[蓝桥杯 2026 国 A] 不互质游戏

Problem Description

Xiaolan and his friend Xiaoqiao are playing a game about positive integers.

At the beginning, there are nn positive integers a1,a2,…,ana_1, a_2, \ldots, a_n on the table. Xiaolan moves first, and the two players take turns.

In one move, a player needs to choose a number xx currently on the table and change it to a smaller positive integer yy. This change is legal if and only if 1≤y<x1 \le y < x and xx and yy are not coprime.

“Not coprime” means the greatest common divisor of the two positive integers is greater than 11, i.e. gcd⁡(x,y)>1\gcd(x, y) > 1. For example, for the number 88, it can be changed to 2,4,62, 4, 6; for the number 1515, it can be changed to 3,5,6,9,10,123, 5, 6, 9, 10, 12. The number 11 and all prime numbers cannot be changed, because there is no smaller positive integer yy 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 TT, representing the number of test cases.

Then TT test cases follow. Each test case consists of two lines:

  • The first line contains a positive integer nn, representing the number of initial numbers.
  • The second line contains nn positive integers a1,a2,…,ana_1, a_2, \ldots, a_n, 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 100100 to 22. After that, 1,3,21, 3, 2 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 40%40\% of the test cases, 1≤n≤101 \le n \le 10, 1≤ai≤30001 \le a_i \le 3000.

For 80%80\% of the test cases, 1≤n≤1001 \le n \le 100, 1≤ai≤200001 \le a_i \le 20000.

For all test cases, 1≤T≤2001 \le T \le 200, 1≤n≤10001 \le n \le 1000, 1≤ai≤3000001 \le a_i \le 300000, and the sum of nn over all test cases does not exceed 100000100000.

Translated by ChatGPT 5