QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613806#5542. Doubled GCDOldera#WA 0ms3608kbC++14918b2024-10-05 14:47:342024-10-05 14:47:34

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 14:47:34]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-10-05 14:47:34]
  • 提交

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;
}

详细

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'