Files
python/TangDou/XiTi/1296.cpp

29 lines
686 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}