forked from Sam071100/CodeForces-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvis_pull2.cpp
More file actions
34 lines (34 loc) · 717 Bytes
/
vis_pull2.cpp
File metadata and controls
34 lines (34 loc) · 717 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
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll lcm(ll a,ll b){
ll g=__gcd(a,b);
return (a*b/g);
}
void solve(){
ll n; cin>>n;
vector<ll> a(n+2,1);
for(ll i=1;i<=n;i++){
cin>>a[i];
}
vector<ll> b(n+2,1);
for(ll i=1;i<=n+1;i++){
b[i]=lcm(a[i],a[i-1]);
}
for(ll i=1;i<=n;i++){
if(__gcd(b[i],b[i+1])!=a[i]){
cout<<"NO\n";
return;
}
}
cout<<"YES\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t; cin>>t;
while(t--){
solve();
}
}