-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLLCM.cpp
More file actions
48 lines (46 loc) · 1.16 KB
/
CLLCM.cpp
File metadata and controls
48 lines (46 loc) · 1.16 KB
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
//Chef vs Doof
////------------------
//Dr Doof has decided to destroy all even numbers from the universe using his Evil-Destroy-inator.
//Chef has N integers with him
//To stop Doof, Chef has to find an odd number which is an integer multiple of all N numbers
//-that he has with him
//find if there exists an odd number which is an integer multiple of all the given N numbers.
//If yes, print "YES", otherwise "NO".
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;cin>>t;
while(t--)
{
//2 4 6 8
//3 6 9
int n,flag = 0;
cin>>n;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
sort(arr,arr+n);
int odd = arr[0];
if(odd!=1)
for(int i=1;i<n;i++)
{
if(odd % 2 == 0 && odd!=1)
{
flag = 1;//Not found
break;
}
else{
if(arr[i] % odd != 0)
{
flag = 1;
break;
}
}
}
if(flag == 0 && odd != 1) cout<<"YES";
else cout<<"NO";
cout<<"\n";
}
return 0;
}