30分TLE求救c⌒っ゚Д゚)っ
查看原帖
30分TLE求救c⌒っ゚Д゚)っ
1068513
ZHUSITAOcccccc楼主2024/7/25 17:36
#include <bits/stdc++.h>
using namespace std;
long long n,h[100005],max1,max2,max3;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	sort(h+1,h+1+n);
	for(int a=1;a<=n-2;a++){
		for(int b=a+1;b<=n-1;b++){
			for(int c=b+1;c<=n;c++){
				if(__gcd(__gcd(h[a],h[b]),h[c])>__gcd(__gcd(max1,max2),max3)){
					max1=h[a];
					max2=h[b];
					max3=h[c];
				}
			}
		}
	}
	cout<<max1<<' '<<max2<<' '<<max3;
    return 0;
}

2024/7/25 17:36
加载中...