QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#701928 | #5542. Doubled GCD | MeatInTheMiddle# | WA | 21ms | 7812kb | C++17 | 1.2kb | 2024-11-02 14:57:17 | 2024-11-02 14:57:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e18 + 5;
const double EPSILON = 1e-14;
const ll DIV = 2000003;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
int n;
ll gcd(ll a, ll b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
pair<ll, ll> arr[200005];
int get(int a)
{
if(a == 0) return 0;
int ret = 0;
while (a % 2 == 0)
ret++, a /= 2;
return ret;
}
priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> pq;
int main()
{
fastio;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> arr[i].second;
arr[i].first = get(arr[i].second);
pq.push(arr[i]);
}
while (pq.size() > 1)
{
pair<ll,ll> a = pq.top();
pq.pop();
pair<ll,ll> b = pq.top();
pq.pop();
ll d = 2 * __gcd(a.second, b.second);
pq.push({get(d), d});
}
cout << pq.top().second;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
input:
3 2 4 6
output:
8
result:
ok single line: '8'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
3 3 5 7
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
4 9 9 9 9
output:
36
result:
ok single line: '36'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
5 10 100 1000 10000 100000
output:
160
result:
ok single line: '160'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
8 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
output:
8000000000
result:
ok single line: '8000000000'
Test #6:
score: 0
Accepted
time: 21ms
memory: 7812kb
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: 3ms
memory: 4108kb
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:
4294967296
result:
wrong answer 1st lines differ - expected: '549755813888', found: '4294967296'