-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path451-min-gcd.cpp
More file actions
42 lines (40 loc) · 1011 Bytes
/
Copy path451-min-gcd.cpp
File metadata and controls
42 lines (40 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* MIN = GCD [2084B]
* Problem: https://codeforces.com/problemset/problem/2084/B
* Verdict: ACCEPTED Solved: 2025-04-05
* Language: C++23 (GCC 14-64, msys2)
* Runtime: 109 ms Memory: 100 KB
* Tags: greedy, math, number theory
* Author: BidoTeima
* Source: https://codeforces.com/contest/2084/submission/314095055
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
int n;
cin>>n;
ll a[n];
for(auto&i:a)cin>>i;
sort(a,a+n);
reverse(a,a+n);
bool ok = 0;
//ll suffmn[n];
//suffmn[n-1]=a[n-1];
//for(int i = n - 2; i >= 0; i--)suffmn[i]=min(suffmn[i+1],a[i]);
ll g = 0;
for(int i = 0; i + 1 < n; i++){
if(a[i]%a[n-1]==0)g=__gcd(g,a[i]);
}
if(g==a[n-1])cout<<"yEs\n";
else cout<<"nO\n";
}
return 0;
}