You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
686 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
int main() {
//cin读入优化
std::ios::sync_with_stdio(false);
//输入+输出重定向
freopen("../1296.txt", "r", stdin);
int n;
cin >> n;
vector<int> a(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int maxx = -1;
//两层循环找到每组组合然后取gcd,打擂台找到最大值
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if (i == j) continue;
maxx = max(maxx, __gcd(a[i], a[j]));
}
}
cout << maxx << endl;
//关闭文件
fclose(stdin);
return 0;
}