| Task: | Sum of ones |
| Sender: | aalto26em_003 |
| Submission time: | 2026-09-28 17:10:50 +0300 |
| Language: | C |
| Status: | READY |
| Result: | RUNTIME ERROR |
| 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.00 s | details |
| #8 | ACCEPTED | 0.00 s | details |
| #9 | ACCEPTED | 0.00 s | details |
| #10 | ACCEPTED | 0.00 s | details |
| #11 | RUNTIME ERROR | 0.00 s | details |
| #12 | RUNTIME ERROR | 0.00 s | details |
| #13 | RUNTIME ERROR | 0.00 s | details |
| #14 | RUNTIME ERROR | 0.00 s | details |
| #15 | RUNTIME ERROR | 0.00 s | details |
| #16 | RUNTIME ERROR | 0.00 s | details |
| #17 | RUNTIME ERROR | 0.00 s | details |
| #18 | RUNTIME ERROR | 0.00 s | details |
| #19 | RUNTIME ERROR | 0.00 s | details |
| #20 | RUNTIME ERROR | 0.00 s | details |
| #21 | RUNTIME ERROR | 0.00 s | details |
Code
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
void readInt(int *i) {
if (scanf("%d", i) != 1)
printf("Trouble reading int!\n");
}
void readll(long long *i) {
if (scanf("%lld", i) != 1)
printf("Trouble reading long long!\n");
}
void readIntArr(int *arr, int size) {
for (int i = 0; i < size; i++)
if (scanf("%d", &arr[i]) != 1)
printf("Trouble reading int array!\n");
}
long long div_floor(long long x, long long y) {
long long q = x / y;
long long r = x % y;
if ((r != 0) && ((r < 0) != (y < 0)))
q--;
return q;
}
int main() {
long long n;
long long *arr;
readll(&n);
arr = calloc(n+1, sizeof(long long));
long long sum = 0;
for(long long i = 1; i <= n; i++) {
long long ww = i;
long long sumsum = 0;
while (ww > 0) {
if(arr[ww] > 0) {
sumsum += arr[ww];
break;
}
if (ww & 1)
sumsum += 1;
ww = ww >> 1;
}
arr[i] = sumsum;
sum += sumsum;
}
printf("%lld\n", sum);
return 0;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1 |
| correct output |
|---|
| 1 |
| user output |
|---|
| 1 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 2 |
| correct output |
|---|
| 2 |
| user output |
|---|
| 2 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 3 |
| correct output |
|---|
| 4 |
| user output |
|---|
| 4 |
Test 4
Verdict: ACCEPTED
| input |
|---|
| 4 |
| correct output |
|---|
| 5 |
| user output |
|---|
| 5 |
Test 5
Verdict: ACCEPTED
| input |
|---|
| 5 |
| correct output |
|---|
| 7 |
| user output |
|---|
| 7 |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 6 |
| correct output |
|---|
| 9 |
| user output |
|---|
| 9 |
Test 7
Verdict: ACCEPTED
| input |
|---|
| 7 |
| correct output |
|---|
| 12 |
| user output |
|---|
| 12 |
Test 8
Verdict: ACCEPTED
| input |
|---|
| 8 |
| correct output |
|---|
| 13 |
| user output |
|---|
| 13 |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 9 |
| correct output |
|---|
| 15 |
| user output |
|---|
| 15 |
Test 10
Verdict: ACCEPTED
| input |
|---|
| 10 |
| correct output |
|---|
| 17 |
| user output |
|---|
| 17 |
Test 11
Verdict: RUNTIME ERROR
| input |
|---|
| 303021765044187 |
| correct output |
|---|
| 7250167017244884 |
| user output |
|---|
| (empty) |
Test 12
Verdict: RUNTIME ERROR
| input |
|---|
| 390977392667778 |
| correct output |
|---|
| 9400236781929604 |
| user output |
|---|
| (empty) |
Test 13
Verdict: RUNTIME ERROR
| input |
|---|
| 670904313808571 |
| correct output |
|---|
| 16399391652009372 |
| user output |
|---|
| (empty) |
Test 14
Verdict: RUNTIME ERROR
| input |
|---|
| 704275111916256 |
| correct output |
|---|
| 17252936460583174 |
| user output |
|---|
| (empty) |
Test 15
Verdict: RUNTIME ERROR
| input |
|---|
| 799807335176164 |
| correct output |
|---|
| 19646099779305746 |
| user output |
|---|
| (empty) |
Test 16
Verdict: RUNTIME ERROR
| input |
|---|
| 852012055430877 |
| correct output |
|---|
| 21005540865890493 |
| user output |
|---|
| (empty) |
Test 17
Verdict: RUNTIME ERROR
| input |
|---|
| 901305628563213 |
| correct output |
|---|
| 22232965316761961 |
| user output |
|---|
| (empty) |
Test 18
Verdict: RUNTIME ERROR
| input |
|---|
| 917427461591619 |
| correct output |
|---|
| 22650112032503064 |
| user output |
|---|
| (empty) |
Test 19
Verdict: RUNTIME ERROR
| input |
|---|
| 981787468874797 |
| correct output |
|---|
| 24322274256024775 |
| user output |
|---|
| (empty) |
Test 20
Verdict: RUNTIME ERROR
| input |
|---|
| 1000000000000000 |
| correct output |
|---|
| 24784747400675348 |
| user output |
|---|
| (empty) |
Test 21
Verdict: RUNTIME ERROR
| input |
|---|
| 989898989898989 |
| correct output |
|---|
| 24531282955144033 |
| user output |
|---|
| (empty) |
