You are viewing a single comment's thread. Return to all comments →
int gcd(int a,int b) { if(b==0) return(a); return(gcd(b,a%b)); } int main() { int t,n,i,j,a[110]; scanf("%d",&t); while(t--) { int f=0; scanf("%d",&n); for(i=0;ia[j]) { if(gcd(a[i],a[j])==1) { f=1; goto A; } } else { if(gcd(a[j],a[i])==1) { f=1; goto A; } } } } A: if(f) { printf("YES\n"); } else { printf("NO\n"); } } return(0); }
Sherlock and GCD
You are viewing a single comment's thread. Return to all comments →
include
int gcd(int a,int b) { if(b==0) return(a); return(gcd(b,a%b)); } int main() { int t,n,i,j,a[110]; scanf("%d",&t); while(t--) { int f=0; scanf("%d",&n); for(i=0;ia[j]) { if(gcd(a[i],a[j])==1) { f=1; goto A; } } else { if(gcd(a[j],a[i])==1) { f=1; goto A; } } } } A: if(f) { printf("YES\n"); } else { printf("NO\n"); } } return(0); }