1 #include<iostream>
2 #include<stdio.h>
3 #include<string.h>
4 #include<algorithm>
5 using namespace std;
6 int a[100050];
7 int s[1005];
8 bool su(int x){
9 if(x%2==0) return false;
10 else {
11 for(int i=3;i*i<=x;i=i+2){
12 if(x%i==0) return false;
13 }
14 return true;
15 }
16 }
17 int main()
18 {
19 int T;
20 s[0]=2;
21 int t=1;
22 for(int i=3;t<1003;i++)
23 if(su(i)){
24 s[t]=i;
25 t++;
26 }
27 cin>>T;
28 while(T--)
29 {
30 int n;
31 scanf("%d",&n);
32 memset(a,0,sizeof(a));
33 for(int i=0;i<n;i++)
34 scanf("%d",&a[i]);
35 bool flag=false;
36 for(int i=0;i<t;i++)
37 {
38 int sum=0;
39 for(int j=0;j<n;j++){
40 if(a[j]%s[i]==0){
41 sum++;
42 }
43 }
44 if(sum==n){
45 flag=true;
46 break;
47 }
48 }
49 if(flag) cout<<"Yes"<<endl;
50 else cout<<"No"<<endl;
51 }
52 return 0;
53 }
1 #include <iostream>
2 #include <cstring>
3 #include <string>
4 #include <queue>
5 #include <vector>
6 #include <map>
7 #include <set>
8 #include <stack>
9 #include <cmath>
10 #include <cstdio>
11 #include <algorithm>
12 #define N 100010
13 #define M 1000000
14 #define LL __int64
15 #define inf 0x3f3f3f3f
16 #define lson l,mid,ans<<1
17 #define rson mid+1,r,ans<<1|1
18 using namespace std;
19 const LL mod = 1e9 + 7;
20 const double eps = 1e-9;
21 LL num[N];
22 LL gcd(LL a, LL b) {
23 return b == 0 ? a : gcd(b, a%b);
24 }
25 int main() {
26 cin.sync_with_stdio(false);
27 int n, T;
28 cin >> T;
29 while (T--) {
30 cin >> n;
31 for (int i = 0; i < n; i++) {
32 cin >> num[i];
33 }
34 if (n == 1) {
35 if (num[0] >= 2) {
36 cout << "Yes" << endl;
37 }
38 else {
39 cout << "No" << endl;
40 }
41 }
42 else {
43 LL ans = gcd(num[0], num[1]);
44 for (int i = 2; i < n; i++) {
45 ans = gcd(ans, num[i]);
46 }
47 if (ans >= 2) {
48 cout << "Yes" << endl;
49 }
50 else {
51 cout << "No" << endl;
52 }
53 }
54 }
55 return 0;
56 }