Submission details
Task:Counting ones
Sender:aalto26hh_012
Submission time:2026-10-28 15:09:04 +0200
Language:C++ (C++23)
Status:READY
Result:
Test results
testverdicttime
#10.46 sdetails
#20.46 sdetails
#30.46 sdetails
#40.46 sdetails
#50.46 sdetails
#60.46 sdetails
#70.46 sdetails
#80.46 sdetails
#90.46 sdetails
#100.46 sdetails

Code

#include <iostream>
#include <bitset>
#include <vector>

int main() {
    int n;
    std::cin >> n;
    std::vector<long long unsigned int> input(n);
    for (int i = 0; i < n; i++) {
        std::cin >> input[i];
    }
    const long long length = 1000000000000000000;
    std::bitset<length> ones(1);
    long long unsigned int curr1 = input[0];
    long long unsigned int curr2 = input[1];
    std::bitset<length> mult{curr1*curr2};
    long long max = (mult & ones).count();
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            mult = {input[i] * input[j]};
            long long tmp = (mult & ones).count();
            if (tmp > max) {
                max = tmp;
                curr1 = input[i];
                curr2 = input[j];
            }
        }
    }
    std::cout << max << '\n' << curr1 << ' ' << curr2 << '\n';
}

Test details

Test 1

Verdict:

input
5
42 100 73 94 1 

correct output
9
42 73

user output
(empty)

Test 2

Verdict:

input
5
44 19 3 94 55 

correct output
8
19 94

user output
(empty)

Test 3

Verdict:

input
10
551 71 709 840 291 122 511 570...

correct output
15
893 438

user output
(empty)

Test 4

Verdict:

input
10
968 901 548 173 973 856 715 61...

correct output
14
715 698

user output
(empty)

Test 5

Verdict:

input
100
221994 55181 870733 831328 206...

correct output
29
396737 649459

user output
(empty)

Test 6

Verdict:

input
100
892861 947477 331980 209407 82...

correct output
29
825210 578859

user output
(empty)

Test 7

Verdict:

input
10000
76308292 227339075 779918796 3...

correct output
50
978548139 589096701

user output
(empty)

Test 8

Verdict:

input
10000
873429404 968540665 239439572 ...

correct output
49
661547021 435157931

user output
(empty)

Test 9

Verdict:

input
10000
10374159 364461027 501874596 4...

correct output
50
313852607 889662850

user output
(empty)

Test 10

Verdict:

input
10000
771320644 298761159 20751947 4...

correct output
49
516789275 257079921

user output
(empty)