QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613806 | #5542. Doubled GCD | Oldera# | WA | 0ms | 3608kb | C++14 | 918b | 2024-10-05 14:47:34 | 2024-10-05 14:47:34 |
Judging History
answer
/*
www.youtube.com/YugiHackerChannel
linktr.ee/YugiHacker
*/
#include<bits/stdc++.h>
#define el cout<<"\n"
#define f0(i,n) for(int i=0;i<n;++i)
#define f1(i,n) for(int i=1;i<=n;++i)
#define maxn
using namespace std;
main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
vector <int> cnt(64);
cin >> n;
long long g = 0;
f1 (i, n) {
int x; cin >> x;
int d = __lg(x & -x);
cnt[d]++;
x /= x & - x;
g = __gcd(g, 1ll * x);
}
int ans = 0;
for (int i=0; i<63; i++) {
cnt[i+1] += cnt[i] / 2;
cnt[i] %= 2;
if (cnt[i]) {
for (int j=i+1; j<63; j++) if (cnt[j]) {
cnt[i+1]++;
cnt[j]--;
cnt[i]--;
}
}
}
for (int i=0; i<63; i++) if (cnt[i] == 1) ans = i;
cout << (1ll << ans) * g;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
3 2 4 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
3 3 5 7
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
4 9 9 9 9
output:
36
result:
ok single line: '36'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
5 10 100 1000 10000 100000
output:
80
result:
wrong answer 1st lines differ - expected: '160', found: '80'