Skip to content

Commit e21c89d

Browse files
committed
Added 1789A - Serval and Mocha's Array.cpp
1 parent 82d5109 commit e21c89d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

1789A - Serval and Mocha's Array.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
// Code Written By: Vikash Patel
5+
6+
bool beautiful(int a[] , int n)
7+
{
8+
int g=INT_MAX;
9+
for(int i=0;i<n;i++)
10+
{
11+
for(int j=i+1;j<n;j++)
12+
{
13+
g=min(__gcd(a[i], a[j]), g);
14+
}
15+
}
16+
if(g>2)
17+
return false;
18+
else
19+
return true;
20+
}
21+
22+
int main()
23+
{
24+
int t;
25+
cin>>t;
26+
while(t--)
27+
{
28+
int n;
29+
cin>>n;
30+
int a[n];
31+
for(int i=0;i<n;i++)
32+
{
33+
cin>>a[i];
34+
}
35+
if(beautiful(a,n))
36+
cout<<"YES"<<endl;
37+
else
38+
cout<<"NO"<<endl;
39+
}
40+
}

0 commit comments

Comments
 (0)