|
|
back to boardWhy 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? хз |
|
|