QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#721626#5542. Doubled GCDsubarudesu#WA 34ms5016kbC++14747b2024-11-07 16:29:332024-11-07 16:29:33

Judging History

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

  • [2024-11-07 16:29:33]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:5016kb
  • [2024-11-07 16:29:33]
  • 提交

answer

#include<iostream>
#include<queue>
#include<algorithm>
#define lowbit(k) ((-k)&k)
using namespace std;
long long n,a[100005],g;
priority_queue<long long>q;
int main(){
    cin>>n;
    for(long long i=1;i<=n;++i){
        cin>>a[i];
        long long low=lowbit(a[i]);
        a[i]/=low;
        if(g==0)g=a[i];
        else g=__gcd(g,a[i]);
        long long x=0;
        while(low>1){
            x++;
            low>>=1;
        }
        q.push(-x);
    }
    while(1){
        if(q.size()<=1)break;
        long long x=q.top();q.pop();
        long long y=q.top();q.pop();
        if(x==y)q.push(x-1);
        else q.push(max(x,y)-1);
    }
    long long x=-q.top();
    cout<<(1<<x)*g<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

3
2 4 6

output:

8

result:

ok single line: '8'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

3
3 5 7

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

4
9 9 9 9

output:

36

result:

ok single line: '36'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

5
10 100 1000 10000 100000

output:

160

result:

ok single line: '160'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

8
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

8000000000

result:

ok single line: '8000000000'

Test #6:

score: 0
Accepted
time: 34ms
memory: 5016kb

input:

100000
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...

output:

65536000000000

result:

ok single line: '65536000000000'

Test #7:

score: -100
Wrong Answer
time: 7ms
memory: 3964kb

input:

20000
33554432 131072 512 128 16777216 524288 64 2 1 32 65536 256 268435456 67108864 262144 2097152 8192 1024 8 128 262144 8388608 32 65536 32 128 256 512 4194304 1024 65536 2 4 4 65536 1 2048 524288 134217728 16 262144 524288 16777216 33554432 1 32768 262144 268435456 2048 4 32 536870912 2 16777216...

output:

128

result:

wrong answer 1st lines differ - expected: '549755813888', found: '128'