Untitled

mail@pastecode.io avatar
unknown
c_cpp
8 months ago
725 B
1
Indexable
Never
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int maxn = 2e6 + 10;
int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i =0 ; i < n; i++) {
        cin >> v[i];
    }
    vector<int> cnt(maxn, 0);
    for(int i = 0; i < n; i++) {
        int sq = sqrt(v[i]);
        for(int j = 1; j <= sq; j++) {
            if(v[i] % j == 0) {
                cnt[j]++;
                if(j != v[i] / j) {
                    cnt[v[i] / j]++;
                }
            }
        }
    }
    for(int i = maxn - 1; i >= 0; i--) {
        if(cnt[i] >= 2) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}