QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591236 | #5465. Maximum GCD | ice_cup# | WA | 48ms | 4028kb | C++14 | 384b | 2024-09-26 14:53:33 | 2024-09-26 14:53:37 |
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]+1)/2<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]+1)/2;
for(int i=1;i*i<=a[1];i++){
if(a[1]%i==0&&ck(n/i)){
ans=max(ans,n/i);
}
}
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3544kb
input:
3 3 10 7
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 48ms
memory: 4028kb
input:
100000 154183567 764881828 59831034 828193326 391773598 487722171 451196811 245718514 750259573 762740115 821999084 28801227 218042831 918898632 881477122 891010192 55732830 509020430 594855913 455478382 456571462 705949609 471532655 550005603 861581472 984465652 883456918 463213251 626620153 371990...
output:
1886
result:
wrong answer 1st numbers differ - expected: '3772', found: '1886'