Teza Round 1 (Codeforces Round 1015, Div. 1 + Div. 2)
B
MIN = GCD
Codeforces
1100
原题
← AC →
翻译中…

You are given a positive integer sequence $a$ of length $n$. Determine if it is possible to rearrange $a$ such that there exists an integer $i$ ($1 \le i \lt n$) satisfying $$ \min([a_1,a_2,\ldots,a_i])=\gcd([a_{i+1},a_{i+2},\ldots,a_n]). $$

翻译中…

Here $\gcd(c)$ denotes the greatest common divisor of $c$, which is the maximum positive integer that divides all integers in $c$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($2 \le n \le 10^5$).

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le 10^{18}$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, output "Yes" if it is possible, and "No" otherwise.

翻译中…

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

翻译中…

Note

翻译中…

In the first test case, rearrange $a$ to $[1,1]$ and let $i=1$, then $\min([1])=\gcd([1])$.

翻译中…

In the second test case, it can be shown that it is impossible.

翻译中…

In the third test case, rearrange $a$ to $[3,2,2]$ and let $i=2$, then $\min([3,2])=\gcd([2])$.

翻译中…

In the fifth test case, rearrange $a$ to $[3,4,5,6,9]$ and let $i=3$, then $\min([3,4,5])=\gcd([6,9])$.

翻译中…

样例

Input #1
7
2
1 1
2
1 2
3
2 2 3
3
2 3 4
5
4 5 6 9 3
3
998244359987710471 99824435698771045 1000000007
6
1 1 4 5 1 4
Output #1
Yes
No
Yes
No
Yes
Yes
Yes
InputCopy OutputCopy
题目信息
题号
2084B
时间限制
1 s
内存限制
256 MB
标签
贪心
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。