ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1278. “… Connecting People”

Why my code got Wrong Answer on #1?
Posted by Loner 24 Jun 2008 23:10
#include <cstdio>

int ncall;
int call[100];

void solve(int K)
{
    if (!K) return;

    if (K % 2 == 0) {
        call[ncall] = ++ncall;
        if (K > 2) solve(K / 2);
    } else {
        call[ncall++] = -1;
        solve(K - 1);
    }
}

int main( void )
{
//    freopen( "p1278.in", "r", stdin );

    int K;
    scanf( "%d", &K );

    if (K > 1) solve(K);
    for (int i = 0; i < ncall; i++)
        printf( "CALL %d\n", call[i] < 0 ? ncall : call[i] );
    printf( "BELL&RET\n" );

    return 0;
}
Re: Why my code got Wrong Answer on #1?
Posted by Loner 24 Jun 2008 23:21
For test #1, K = 4, and my code output:
CALL 1
CALL 2
BELL&RET
I think it's correct.
Re: Why my code got Wrong Answer on #1?
Posted by Maximilian De Lesion 30 Sep 2024 23:33
хз