QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#383225#5542. Doubled GCDFOY#WA 35ms4344kbC++23518b2024-04-09 05:40:032024-04-09 05:40:04

Judging History

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

  • [2024-04-09 05:40:04]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:4344kb
  • [2024-04-09 05:40:03]
  • 提交

answer

#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
using namespace std;
using ll = long long;

int main() {
	auto cmp = [&](ll i, ll j) {
		return __builtin_ctz(i) > __builtin_ctz(j);
	};
	priority_queue<ll, vector<ll>, decltype(cmp)> pq(cmp);
	ll n; cin >> n;
	for (ll i = 0; i < n; i++) {
		ll x; cin >> x;
		pq.push(x);
	}
	while (pq.size() >= 2) {
		ll a = pq.top();
		pq.pop();
		ll b = pq.top();
		pq.pop();
		pq.push(2*gcd(a,b));
	}
	cout << pq.top() << endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3832kb

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: 3840kb

input:

4
9 9 9 9

output:

36

result:

ok single line: '36'

Test #4:

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

input:

5
10 100 1000 10000 100000

output:

160

result:

ok single line: '160'

Test #5:

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

input:

8
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

8000000000

result:

ok single line: '8000000000'

Test #6:

score: 0
Accepted
time: 35ms
memory: 4344kb

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: 6ms
memory: 3664kb

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:

17179869184

result:

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