fork download
  1. #include <iostream>
  2. #include<queue>
  3. #include <algorithm>
  4. #include <map>
  5. #include<unordered_map>
  6. #include <set>
  7. #include <fstream>
  8. #include <vector>
  9. #include <math.h>
  10. #include <iomanip>
  11. #include <string>
  12. #include <cstring>
  13. using namespace std;
  14.  
  15. #define ll long long
  16.  
  17. ll mod = 1e9+7;
  18. const int N = 1e6;
  19. int MOD = 998244353;
  20. int bit[200000];
  21. ll dem=0;
  22.  
  23. int main() {
  24. //freopen("CSBN.INP", "r", stdin);
  25. //freopen("CSBN.OUT", "w", stdout);
  26. int n;
  27. cin >> n;
  28. int x;
  29.  
  30. unordered_map<int,int> cnt;
  31. for(int i=1;i<=n;i++){
  32. cin >> x;
  33.  
  34. cnt[x]++;
  35. }
  36. for(int i = N; i >= 1; i--){
  37. int k = 0;
  38. for(int j=i; j<=N;j+=i){
  39. k += cnt[j];
  40. }
  41. if(k >= 2){
  42. cout << i;
  43. return 0;
  44. }
  45. }
  46. }
Success #stdin #stdout 0.7s 42640KB
stdin
5
3 14 15 7 9
stdout
7