Codeforces Round 929 (Div. 3) D. Turtle Tenacity: Continual Mods
Will Chang
Posted on April 2, 2024
/*
by looking at the test cases, I discovered that
if we divide the array numbers by the gcd of the
whole array(we call this array A), if there are
more than one 1's in it, then "NO", or else "YES"
pf. just write the array in increasing order and
it is obvious
*/
#include<bits/stdc++.h>
using namespace std;
int arr[100005]={0};
int main(){
int t; cin>>t;
for (int tt=0; tt!=t; tt++){
for (int i=0; i!=100005; i++){
arr[i] = 0;
}
int n; cin>>n;
int x; cin>>x;
int g = x;
arr[0]=x;
for (int i=1; i!=n; i++){
int num; cin>>num;
arr[i] = num;
g = __gcd(num,g);
}
for (int i=0; i!=n; i++){
arr[i] = arr[i]/g;
}
int ok = 0;
for (auto u:arr){
if (u==1){
ok += 1;
}
}
//cout<<g<<"\n";
if (ok>1){
cout<<"NO"<<"\n";
}
else{
cout<<"YES"<<"\n";
}
}
}
💖 💪 🙅 🚩
Will Chang
Posted on April 2, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
githubcopilot AI Innovations at Microsoft Ignite 2024 What You Need to Know (Part 2)
November 29, 2024