QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#680014#5465. Maximum GCDsakibmustafaTL 0ms0kbC++14471b2024-10-26 19:32:292024-10-26 19:32:29

Judging History

你现在查看的是最新测评结果

  • [2024-10-26 19:32:29]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-26 19:32:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{
	int n;
	cin>>n;
	vector<int> a(n);

	for(int i = 0 ; i < n ; i++) 
		cin>>a[i];
	sort(a.begin(),a.end());
	int mn = a[0],flag = 1;

	while(mn>=1){
	for(int i = 1; i < n ; i++)
	{
		if(mn<=a[i]/2)
			break;
		if(a[i] != mn && a[i]%mn != 0){
			flag=0;
			break;
		}
	}
	if(flag){
		cout<<mn<<endl;
	}
	else{
		mn/=2;
	}
}
cout<<max(mn,1ll)<<endl;
	
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
3 10 7

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
...

result: