QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#769048 | #5465. Maximum GCD | TauLee01 | WA | 22ms | 8848kb | C++17 | 968b | 2024-11-21 15:54:18 | 2024-11-21 15:54:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int n;
void solve() {
cin >> n;
map<int, int>mp;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
sort(a + 1, a + 1 + n);
if (count(a + 1, a + 1 + n, a[1]) == n)
{
cout << a[1] << '\n';
return;
}
for (int i = 1; i <= n; i++)
{
if (a[i] % a[1])
{
mp[a[i]]++;
}
}
if (mp.empty())
{
cout << a[1] << '\n';
return;
}
auto pp = mp.begin();
auto val = (*pp).first;
int res = a[1];
if (res <= (val + 1) / 2 - 1)
{
cout << res << '\n';
return;
}
res = (res + 1) / 2;
cout << max(res, 1) << '\n';
}
signed main()
{
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int _ = 1;
// cin >> _;
while (_--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
input:
3 3 10 7
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: 0
Accepted
time: 22ms
memory: 8600kb
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: 7ms
memory: 4160kb
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: 0
Accepted
time: 7ms
memory: 4020kb
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...
output:
499999500
result:
ok 1 number(s): "499999500"
Test #5:
score: 0
Accepted
time: 22ms
memory: 8848kb
input:
100000 2339018 1749754 3376731 9508803 1986463 3632005 6226628 1462120 8271360 8846247 8379452 2960858 1687623 3059513 9805949 8592853 4763971 6382780 1552229 8402035 9055846 6039035 1412389 9103272 3160554 4293404 4986833 7422294 1031511 3281256 7401944 2250268 1895990 1052625 6425782 1547099 61500...
output:
500018
result:
ok 1 number(s): "500018"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
1 4360
output:
4360
result:
ok 1 number(s): "4360"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
2 709714 1581844
output:
709714
result:
ok 1 number(s): "709714"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
10 546260421 852755840 481560053 275469550 908149678 453897265 988292618 110888697 95642218 528793626
output:
47821109
result:
ok 1 number(s): "47821109"
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
100 110842178 108800257 72759981 167863159 126815647 147998087 156926565 92960393 163090092 142384022 164406682 156939726 136887138 165468770 134596858 223474322 97825730 140041433 214450935 101221271 164581907 111738193 95079147 118597457 15464369 146274776 13173492 208648228 55473866 144762527 190...
output:
3632470
result:
wrong answer 1st numbers differ - expected: '3632469', found: '3632470'