QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#306772 | #5542. Doubled GCD | NYCU_CartesianTree# | WA | 0ms | 3720kb | C++20 | 741b | 2024-01-17 10:23:03 | 2024-01-17 10:23:04 |
Judging History
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'