QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#383221 | #5542. Doubled GCD | FOY# | WA | 0ms | 3836kb | C++23 | 504b | 2024-04-09 05:37:26 | 2024-04-09 05:37:27 |
Judging History
answer
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;
int main() {
auto cmp = [&](int i, int j) {
return __builtin_ctz(i) > __builtin_ctz(j);
};
priority_queue<int, vector<int>, decltype(cmp)> pq(cmp);
int n; cin >> n;
for (int i = 0; i < n; i++) {
int x; cin >> x;
pq.push(x);
}
while (pq.size() >= 2) {
int a = pq.top();
pq.pop();
int b = pq.top();
pq.pop();
pq.push(2*gcd(a,b));
}
cout << pq.top() << endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3608kb
input:
3 2 4 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 3 5 7
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
4 9 9 9 9
output:
36
result:
ok single line: '36'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
5 10 100 1000 10000 100000
output:
160
result:
ok single line: '160'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
8 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
output:
589934592
result:
wrong answer 1st lines differ - expected: '8000000000', found: '589934592'