Task: | Sum of ones |
Sender: | aalto2024e_005 |
Submission time: | 2024-09-30 16:44:32 +0300 |
Language: | C++ (C++20) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | WRONG ANSWER | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | WRONG ANSWER | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | WRONG ANSWER | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | WRONG ANSWER | 0.00 s | details |
#9 | WRONG ANSWER | 0.00 s | details |
#10 | WRONG ANSWER | 0.00 s | details |
#11 | WRONG ANSWER | 0.00 s | details |
#12 | WRONG ANSWER | 0.00 s | details |
#13 | WRONG ANSWER | 0.00 s | details |
#14 | WRONG ANSWER | 0.00 s | details |
#15 | WRONG ANSWER | 0.00 s | details |
#16 | WRONG ANSWER | 0.00 s | details |
#17 | WRONG ANSWER | 0.00 s | details |
#18 | WRONG ANSWER | 0.00 s | details |
#19 | WRONG ANSWER | 0.00 s | details |
#20 | WRONG ANSWER | 0.00 s | details |
#21 | WRONG ANSWER | 0.00 s | details |
Code
#include <iostream> #include <vector> #include <string> #include <math.h> using namespace std; long long largest_power(long long n){ if (!(n & (n - 1))) return n; int p = (long long)log2(n); return (long long)pow(2, p-1); } long long count(long long n){ if (n <= 1) return n; long long x = largest_power(n); return (x * pow(2, (x-1)) + (n- pow(2, x) +1) + count(n - pow(2, x))); } int main() { long long n; cin >> n; cout << count(n) << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 2
Verdict: WRONG ANSWER
input |
---|
2 |
correct output |
---|
2 |
user output |
---|
1 |
Test 3
Verdict: ACCEPTED
input |
---|
3 |
correct output |
---|
4 |
user output |
---|
4 |
Test 4
Verdict: WRONG ANSWER
input |
---|
4 |
correct output |
---|
5 |
user output |
---|
9 |
Test 5
Verdict: ACCEPTED
input |
---|
5 |
correct output |
---|
7 |
user output |
---|
7 |
Test 6
Verdict: WRONG ANSWER
input |
---|
6 |
correct output |
---|
9 |
user output |
---|
8 |
Test 7
Verdict: ACCEPTED
input |
---|
7 |
correct output |
---|
12 |
user output |
---|
12 |
Test 8
Verdict: WRONG ANSWER
input |
---|
8 |
correct output |
---|
13 |
user output |
---|
529 |
Test 9
Verdict: WRONG ANSWER
input |
---|
9 |
correct output |
---|
15 |
user output |
---|
19 |
Test 10
Verdict: WRONG ANSWER
input |
---|
10 |
correct output |
---|
17 |
user output |
---|
21 |
Test 11
Verdict: WRONG ANSWER
input |
---|
303021765044187 |
correct output |
---|
7250167017244884 |
user output |
---|
-9223372036854775808 |
Test 12
Verdict: WRONG ANSWER
input |
---|
390977392667778 |
correct output |
---|
9400236781929604 |
user output |
---|
-9223372036854775808 |
Test 13
Verdict: WRONG ANSWER
input |
---|
670904313808571 |
correct output |
---|
16399391652009372 |
user output |
---|
-9223372036854775808 |
Test 14
Verdict: WRONG ANSWER
input |
---|
704275111916256 |
correct output |
---|
17252936460583174 |
user output |
---|
-9223372036854775808 |
Test 15
Verdict: WRONG ANSWER
input |
---|
799807335176164 |
correct output |
---|
19646099779305746 |
user output |
---|
-9223372036854775808 |
Test 16
Verdict: WRONG ANSWER
input |
---|
852012055430877 |
correct output |
---|
21005540865890493 |
user output |
---|
-9223372036854775808 |
Test 17
Verdict: WRONG ANSWER
input |
---|
901305628563213 |
correct output |
---|
22232965316761961 |
user output |
---|
-9223372036854775808 |
Test 18
Verdict: WRONG ANSWER
input |
---|
917427461591619 |
correct output |
---|
22650112032503064 |
user output |
---|
-9223372036854775808 |
Test 19
Verdict: WRONG ANSWER
input |
---|
981787468874797 |
correct output |
---|
24322274256024775 |
user output |
---|
-9223372036854775808 |
Test 20
Verdict: WRONG ANSWER
input |
---|
1000000000000000 |
correct output |
---|
24784747400675348 |
user output |
---|
-9223372036854775808 |
Test 21
Verdict: WRONG ANSWER
input |
---|
989898989898989 |
correct output |
---|
24531282955144033 |
user output |
---|
-9223372036854775808 |