-
Notifications
You must be signed in to change notification settings - Fork 0
/
Differece_Operation.cpp
63 lines (61 loc) · 1.53 KB
/
Differece_Operation.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define has(s, key) (s.find(key) != s.end())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define vi vector<int>
#define vl vector<ll>
#define v(a) vector<a>
#define si set<int>
#define usi unordered_set<int>
#define pii pair<int, int>
#define vpp vector<pair<int, pii>>
#define rset(dp) memset(dp,-1,sizeof(dp))
#define pq_max priority_queue<int>
#define pq_min priority_queue<int, vi, greater<int>>
#define print(a) for(auto x : a) cout<<x<<" "; cout<<endl
#define printp(a) for(auto x : a) cout<<x.F<<" "<<x.S<<endl
#define printa(a,x,y) for(int i = x; i < y ; i++) cout<<a[i]<<" "; cout<<endl
#define F first
#define S second
#define pb push_back
#define mii map<int,int>
#define umii unordered_map<int,int>
#define umap unordered_map
#define all(p) b.begin(), p.end()
#define ina(a, n) for(int i=0;i<n;i++) cin>>a[i]
#define inp(a, n) for(int i=0;i<n;i++) cin>>a[i].F>>a[i].S;
#define inq(q,n,t) for(int i=0;i<n;i++) for(int j=0;j<t;j++) cin>>q[i][j]
bool diff(vector<int>& arr, int n) {
int i, j;
for(i = 1; i < n ; i++) {
if(arr[i] == 0)
continue;
for(j = 0; j < i ; j++) {
if(arr[j] == 0)
continue;
if(arr[i] % arr[j] == 0)
break;
}
if(j == i)
return false;
}
return true;
}
int main(void) {
fast;
int t, n;
cin>>t;
while(t--) {
cin>>n;
vector<int> arr(n);
for(int i=0;i<n;i++)
cin>>arr[i];
if(diff(arr, n))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}