#P10443. 「MYOI-R3」消消乐

    ID: 11558 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>洛谷原创O2优化最大公约数 gcd洛谷月赛

「MYOI-R3」消消乐

Background

upd 2024/5/12 18:14: Added two sets of hack testdata, located in Subtask 1, worth 00 points.

upd 2024/5/12 21:27: Added one set of hack testdata, located in Subtask 1, worth 00 points.

Problem Description

Given a sequence aa of length nn.

Define one operation as choosing three integers x,y,z[1,n]x,y,z\in[1,n] such that gcd(ax,ay)=az\gcd(a_x,a_y)=a_z and x,y,zx,y,z are pairwise distinct, then eliminate aza_z (that is, in later operations you can no longer choose aza_z).

Ask whether, after some number of operations, it is possible to eliminate n2n-2 numbers among a1ana_1\sim a_n.

Input Format

The first line contains a positive integer TT, indicating the number of test cases.

For each test case:

The first line contains a positive integer nn.

The second line contains nn positive integers aia_i.

Output Format

For each test case, output one line containing a string Yes or No.

2
3
1 2 3
3
1 2 4
Yes
No

Hint

Sample Explanation:

  • For the first test case, you can eliminate 11 using (2,3)(2,3).
  • For the second test case, it can be proven that there is no solution.

Constraints

There are 2020 test points in total, and each test point is worth 55 points.

For 100%100\% of the data, 1T1051\le T\le 10^5, 2n1062\leq n \leq 10^6, 2n1062 \le \sum n\le 10^6, 1ai1091\le a_i\le 10^9.

Translated by ChatGPT 5