QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#582951 | #5542. Doubled GCD | surenjamts# | WA | 0ms | 4148kb | C++20 | 535b | 2024-09-22 17:50:46 | 2024-09-22 17:50:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int32_t main(){
int n;
cin >> n;
vector<int> v(n);
priority_queue<int, vector<int>, greater<int>> q;
int g = 0;
for(auto &i : v) {
cin >> i;
int cnt = 0;
while(i%2 == 0) cnt++, i/=2;
q.push(cnt);
// cout << cnt << endl;
g = __gcd(g, i);
}
while(q.size() > 1){
int f = q.top(); q.pop();
int s = q.top(); q.pop();
// cout << f << " " << s << endl;
q.push(min(f, s) + 1);
}
cout << pow(2, q.top()) * g;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4112kb
input:
3 2 4 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4148kb
input:
3 3 5 7
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
4 9 9 9 9
output:
36
result:
ok single line: '36'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4148kb
input:
5 10 100 1000 10000 100000
output:
160
result:
ok single line: '160'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 4104kb
input:
8 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
output:
8e+09
result:
wrong answer 1st lines differ - expected: '8000000000', found: '8e+09'