QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591246 | #5465. Maximum GCD | ice_cup# | WA | 0ms | 3612kb | C++14 | 386b | 2024-09-26 14:56:35 | 2024-09-26 14:56:35 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,a[100100],ans;
bool ck(int x){
int fl=1;
for(int i=1;i<=n;i++){
if(a[i]%x!=0&&a[i]/2-1<x)fl=0;
}
return fl;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
sort(a+1,a+1+n);
ans=a[1]/2-1;
for(int i=1;i*i<=a[1];i++){
if(a[1]%i==0&&ck(a[1]/i)){
ans=max(ans,a[1]/i);
}
}
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3612kb
input:
3 3 10 7
output:
0
result:
wrong answer 1st numbers differ - expected: '3', found: '0'