| Task: | Counting ones |
| Sender: | aalto26hh_009 |
| Submission time: | 2026-10-25 18:18:25 +0200 |
| Language: | C++ (C++23) |
| 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.20 s | details |
| #8 | ACCEPTED | 0.20 s | details |
| #9 | ACCEPTED | 0.20 s | details |
| #10 | ACCEPTED | 0.20 s | details |
Compiler report
input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i=0; i<numbers.size(); i++) {
| ~^~~~~~~~~~~~~~~
input/code.cpp:20:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long unsigned int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int j=i+1; j<numbers.size(); j++) {
| ~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/iostream:41,
from input/code.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main(int, char**)' at input/code.cpp:33:18:...Code
#include <iostream>
#include <vector>
#include <bitset>
int main(int argc, char **argv) {
int n;
std::cin >> n;
std::vector<unsigned long long> numbers(n);
for (int i=0; i<n; i++) {
std::cin >> numbers[i];
}
int best_numbers_of_ones = 0;
unsigned long long a;
unsigned long long b;
for (int i=0; i<numbers.size(); i++) {
for (int j=i+1; j<numbers.size(); j++) {
std::bitset<64> multiplication_in_bits = numbers.at(i) * numbers.at(j);
int numbers_of_ones = multiplication_in_bits.count();
if (numbers_of_ones > best_numbers_of_ones) {
best_numbers_of_ones = numbers_of_ones;
a = numbers.at(i);
b = numbers.at(j);
}
}
}
std::cout << best_numbers_of_ones << std::endl;
std::cout << a << " " << b << std::endl;
return 0;
}
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 |
