1 /* 2 UVA11827 Maximum GCD 3 https://vjudge.net/contest/153365#problem/V 4 数论 gcd 5 水题,然而读入比较坑 6 * 7 */ 8 #include <cstdio> 9 #include <algorithm> 10 #include <cstring> 11 #include <cmath> 12 #include <vector> 13 #include <queue> 14 //#define test 15 using namespace std; 16 const int Nmax=1005; 17 18 long long gcd(long long a,long long b) 19 { 20 if(b==0LL) 21 return a; 22 return gcd(b,a%b); 23 } 24 long long num[Nmax]; 25 26 int read(long long &a) 27 { 28 long long ans=0LL; 29 char c=getchar(); 30 while(c==' ') 31 c=getchar(); 32 int flag=1; 33 while(c>='0' && c<='9') 34 { 35 flag=0; 36 ans=ans*10LL+c-'0'; 37 c=getchar(); 38 } 39 if(flag) 40 { 41 a=1LL; 42 return 0; 43 } 44 a=ans; 45 if(c==' ') 46 { 47 //a=1LL; 48 return 0; 49 } 50 return 1; 51 } 52 53 int main() 54 { 55 #ifdef test 56 freopen("uva.in","r",stdin); 57 #endif 58 int n; 59 scanf("%d",&n); 60 getchar(); 61 while(n--) 62 { 63 long long mmax=-1LL; 64 int m=0; 65 while(read(num[++m])); 66 //for(int i=1;i<=m;i++) 67 //printf("%d ",num[i]); 68 //printf(" "); 69 for(int i=1;i<=m;i++) 70 { 71 for(int j=i+1;j<=m;j++) 72 { 73 mmax=max(mmax,gcd(num[i],num[j])); 74 } 75 } 76 printf("%lld ",mmax); 77 } 78 return 0; 79 }