QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#591273 | #5465. Maximum GCD | ice_cup# | TL | 30ms | 3976kb | C++14 | 369b | 2024-09-26 15:05:20 | 2024-09-26 15:05:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,a[100100],ans;
bool ck(int x){
for(int i=1;i<=n;i++){
if(a[i]%x!=0&&(a[i]-1)/2<x)return 0;
}
return 1;
}
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<=a[1];i++){
if(a[1]%i==0&&ck(i)){
ans=max(ans,i);
}
}
cout<<ans;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3576kb
input:
3 3 10 7
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 30ms
memory: 3972kb
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:
3772
result:
ok 1 number(s): "3772"
Test #3:
score: 0
Accepted
time: 11ms
memory: 3976kb
input:
100000 80 88 53 77 74 63 57 71 75 74 27 14 38 23 24 75 33 89 81 33 100 56 53 77 55 54 63 80 100 15 70 24 100 65 95 22 34 12 31 30 83 20 68 87 23 53 53 55 72 13 57 94 27 94 93 81 96 57 11 81 18 53 34 67 77 65 38 45 45 33 66 47 56 61 60 55 13 61 60 83 24 68 88 50 59 44 27 99 22 82 16 96 62 60 98 48 78...
output:
5
result:
ok 1 number(s): "5"
Test #4:
score: -100
Time Limit Exceeded
input:
100000 999999598 999999894 999999159 999999706 999999201 999999362 999999889 999999054 999999169 999999662 999999967 999999278 999999478 999999996 999999011 999999630 999999240 999999446 999999989 999999526 999999874 999999704 999999555 999999997 999999622 999999847 999999791 999999729 999999697 999...