#include <iostream>
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
int main ()
{
int test ,i,a[10000],c,j,b[1000],x;
char str[10000],*pch;
cin>>test;
getchar();
while(test--){
gets(str);
c=0;x=0;
pch=strtok(str," ");
while(pch!=NULL){
c++;
a[c]= atoi(pch);;
pch=strtok(NULL," ");
}
for(i=1;i<=c;i++){
for(j=1;j<=c;j++){
if(a[i]!=a[j]){
x++;
b[x] =gcd(a[i],a[j]);
}
}
}
sort(b,b+x+1);
printf("%d\n",b[x]);
}
return 0;
}
#include <cstdio>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
int main ()
{
int test ,i,a[10000],c,j,b[1000],x;
char str[10000],*pch;
cin>>test;
getchar();
while(test--){
gets(str);
c=0;x=0;
pch=strtok(str," ");
while(pch!=NULL){
c++;
a[c]= atoi(pch);;
pch=strtok(NULL," ");
}
for(i=1;i<=c;i++){
for(j=1;j<=c;j++){
if(a[i]!=a[j]){
x++;
b[x] =gcd(a[i],a[j]);
}
}
}
sort(b,b+x+1);
printf("%d\n",b[x]);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন