题解
2023-08-15 10:59:43
发布于:广东
9阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main() {
int t,n,f;
cin >> t;
for (int i=1;i<=t;i++){
cin >> n;
int a[1010] = {0};
for (int i = 1; i <= n; i++) {
cin >> f;
a[f] = i;
}
int cnt = -1;
for (int i = 1; i <= 1000; i++) {
for (int j = i; j <= 1000; j++) {
if (a[i] && a[j] && __gcd(i,j)==1 && a[i]+a[j]>cnt) cnt=a[i]+a[j];
}
}
cout << cnt << "\n";
}
return 0;
}
这里空空如也
有帮助,赞一个