QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#306772#5542. Doubled GCDNYCU_CartesianTree#WA 0ms3720kbC++20741b2024-01-17 10:23:032024-01-17 10:23:04

Judging History

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

  • [2024-01-17 10:23:04]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3720kb
  • [2024-01-17 10:23:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define ing long long 
#define F first 
#define S second 
#define pb push_back 

int d(int t1){
    int c1=0,c2=0;
    while(t1%2==0) t1/=2,c1++;
    return c1;
}

void solve(){
    int n;
    cin>>n;
    vector<int>a(n+1);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>>now;
    for(int i=1;i<=n;i++) cin>>a[i],now.push({d(a[i]),a[i]});


    while(now.size()>1){
        auto t1=now.top();now.pop();
        auto t2=now.top();now.pop();
        int v=__gcd(t1.S,t2.S)*2;
        int dd=d(v);
        now.push({dd,v});
    }
    cout<<now.top().S<<"\n";
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);
    solve();
    return 0;
}

詳細信息

Test #1:

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

input:

3
2 4 6

output:

8

result:

ok single line: '8'

Test #2:

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

input:

3
3 5 7

output:

2

result:

ok single line: '2'

Test #3:

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

input:

4
9 9 9 9

output:

36

result:

ok single line: '36'

Test #4:

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

input:

5
10 100 1000 10000 100000

output:

160

result:

ok single line: '160'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3512kb

input:

8
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

-589934592

result:

wrong answer 1st lines differ - expected: '8000000000', found: '-589934592'