fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned long long
  5. #define all(a) (a).begin(), (a).end()
  6. const int maxn = 1e6 + 1;
  7. ll res = 0, status = 1;
  8. void ham(ll x, ll n) {
  9. if (n == 0) {
  10. cout << status;
  11. return;
  12. }
  13. status += status * x;
  14. ham(x, n - 1);
  15. }
  16. vector<int> a;
  17. map<int, int> freq;
  18. int main() {
  19. ios_base::sync_with_stdio(false);
  20. cin.tie(0);
  21. cout.tie(0);
  22. int n, x;
  23. cin >> n;
  24. int ma = 0;
  25. for (int i = 0; i < n; i++) {
  26. cin >> x;
  27. a.push_back(x);
  28. freq[a[i]]++;
  29. ma = max(ma, x);
  30. }
  31. for (int g = ma; g >= 1; g--) {
  32. int count = 0;
  33. for (int i = g; i <= ma; i += g) {
  34. count += freq[i];
  35. if (count >= 2) { // Nếu tìm thấy ít nhất 2 số chia hết cho g
  36. cout << g << endl;
  37. return 0;
  38. }
  39. }
  40. }
  41.  
  42. }
  43.  
  44.  
  45.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty