| Task: | Counting ones |
| Sender: | aalto26hh_050 |
| Submission time: | 2026-10-24 15:16:59 +0300 |
| Language: | C++ (C++20) |
| Status: | READY |
| Result: | ACCEPTED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.00 s | details |
| #2 | ACCEPTED | 0.00 s | details |
| #3 | ACCEPTED | 0.00 s | details |
| #4 | ACCEPTED | 0.00 s | details |
| #5 | ACCEPTED | 0.00 s | details |
| #6 | ACCEPTED | 0.00 s | details |
| #7 | ACCEPTED | 0.26 s | details |
| #8 | ACCEPTED | 0.26 s | details |
| #9 | ACCEPTED | 0.26 s | details |
| #10 | ACCEPTED | 0.26 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:37:37: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
37 | cout << max << "\n" << a << " " << b;
| ^~~
input/code.cpp:24:20: note: 'a' was declared here
24 | int count, a, b, max;
| ^
input/code.cpp:37:44: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
37 | cout << max << "\n" << a << " " << b;
| ^
input/code.cpp:24:23: note: 'b' was declared here
24 | int count, a, b, max;
| ^Code
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
vector<ll> arr;
int n;
cin >> n;
ll x;
rep(i, 0, n) {
cin >> x;
arr.push_back(x);
}
int count, a, b, max;
max = 0;
rep(i, 0, n) {
rep(j, i, n) {
x = arr[i] * arr[j];
count = __builtin_popcountll(x);
if (count > max) {
max = count;
a = arr[i];
b = arr[j];
}
}
}
cout << max << "\n" << a << " " << b;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 5 42 100 73 94 1 |
| correct output |
|---|
| 9 42 73 |
| user output |
|---|
| 9 42 73 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 5 44 19 3 94 55 |
| correct output |
|---|
| 8 19 94 |
| user output |
|---|
| 8 19 94 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 10 551 71 709 840 291 122 511 570... |
| correct output |
|---|
| 15 893 438 |
| user output |
|---|
| 15 893 438 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 10 968 901 548 173 973 856 715 61... |
| correct output |
|---|
| 14 715 698 |
| user output |
|---|
| 14 715 698 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 100 221994 55181 870733 831328 206... |
| correct output |
|---|
| 29 396737 649459 |
| user output |
|---|
| 29 396737 649459 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 100 892861 947477 331980 209407 82... |
| correct output |
|---|
| 29 825210 578859 |
| user output |
|---|
| 29 825210 578859 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 10000 76308292 227339075 779918796 3... |
| correct output |
|---|
| 50 978548139 589096701 |
| user output |
|---|
| 50 978548139 589096701 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 10000 873429404 968540665 239439572 ... |
| correct output |
|---|
| 49 661547021 435157931 |
| user output |
|---|
| 49 661547021 435157931 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 10000 10374159 364461027 501874596 4... |
| correct output |
|---|
| 50 313852607 889662850 |
| user output |
|---|
| 50 313852607 889662850 |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 10000 771320644 298761159 20751947 4... |
| correct output |
|---|
| 49 516789275 257079921 |
| user output |
|---|
| 49 516789275 257079921 |
