算法
(暴力枚举)
注意到 $X_i$ 最大可以取到 $50$,而 $50$ 以内的素数只有 $15$ 个,一共有 $2^{15}$ 个可能的数,这个数字不是很大,所以直接按要求暴力枚举即可。
C++ 代码
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using std::cin;
using std::cout;
using std::min;
using std::gcd;
using std::vector;
using ll = long long;
const ll LINF = 1001002003004005006ll;
// linear sieve
vector<int> ps, pf;
void sieve(int mx) {
pf.resize(mx + 1);
rep(i, mx + 1) pf[i] = i;
for (int i = 2; i <= mx; ++i) {
if (pf[i] == i) ps.push_back(i);
for (int j = 0; j < ps.size() and ps[j] <= pf[i]; ++j) {
int x = ps[j] * i;
if (x > mx) break;
pf[x] = ps[j];
}
}
}
int main() {
sieve(50);
int n;
cin >> n;
vector<int> a(n);
rep(i, n) cin >> a[i];
ll ans = LINF;
int m = ps.size();
int m2 = 1 << m;
rep(i, m2) {
ll x = 1;
rep(j, m) if (i >> j & 1) x *= ps[j];
bool ok = true;
rep(j, n) if (gcd(x, a[j]) == 1) ok = false;
if (ok) ans = min(ans, x);
}
cout << ans << '\n';
return 0;
}