fork download
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. # define fi cin
  4. # define fo cout
  5. # define x first
  6. # define y second
  7. # define ll long long
  8. # define db long double
  9. # define scn(x) scanf("%I64d",&x)
  10. # define scan(x) scanf("%d",&x)
  11. # define print(x) printf("%d ",x)
  12. # define prnt(x) printf("%I64d ",x);
  13. # define eol printf("\n")
  14. # define IOS ios_base :: sync_with_stdio(0)
  15. int s[1 << 20];
  16. int main(void)
  17. {
  18. int t;
  19. scan(t);
  20. while (t --)
  21. {
  22. int n;
  23. scan(n);
  24. int mn = 1e9;
  25. for (int i = 1;i <= n;++i) scan(s[i]),mn = min(mn,s[i]);
  26. int ans = 0;
  27. vector < int > can;
  28. for (int i = 1;i * i <= mn;++i)
  29. if (!(mn % i))
  30. {
  31. can.push_back(i);
  32. if (1ll * i * i != mn) can.push_back(mn / i);
  33. }
  34. for (auto P : can)
  35. {
  36. int G = 0;
  37. for (int i = 1;i <= n;++i)
  38. if (s[i] % P) G = __gcd(G,s[i]);
  39. if (!G) G = 1e9;
  40. ans = max(ans,min(G,P));
  41. }
  42. print(ans);eol;
  43. }
  44. return 0;
  45. }
  46.  
  47.  
Runtime error #stdin #stdout 0.45s 7552KB
stdin
Standard input is empty
stdout
Standard output is empty