QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#680014 | #5465. Maximum GCD | sakibmustafa | TL | 0ms | 0kb | C++14 | 471b | 2024-10-26 19:32:29 | 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 ...