QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#383221#5542. Doubled GCDFOY#WA 0ms3836kbC++23504b2024-04-09 05:37:262024-04-09 05:37:27

Judging History

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

  • [2024-04-09 05:37:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3836kb
  • [2024-04-09 05:37:26]
  • 提交

answer

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

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 4 6

output:

8

result:

ok single line: '8'

Test #2:

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

input:

3
3 5 7

output:

2

result:

ok single line: '2'

Test #3:

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

input:

4
9 9 9 9

output:

36

result:

ok single line: '36'

Test #4:

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

input:

5
10 100 1000 10000 100000

output:

160

result:

ok single line: '160'

Test #5:

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

input:

8
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

output:

589934592

result:

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