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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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;
}