For the following GNU C code, I got 9AC + 1WA. I thought my algorithm is correct and there must be some bug in my code.
Could we de"bug"?
#include <stdio.h>long long b[] = {1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907, 43046721, 129140163, 387420489, 1162261467, 3486784401, 10460353203, 31381059609, 94143178827, 282429536481, 847288609443, 2541865828329, 7625597484987, 22876792454961, 68630377364883, 205891132094649, 617673396283947};
int main()
{
unsigned n;
int k;while( scanf(\"%d\", &n) != -1 )
{
if(n==1)
{
printf(\"\n\");
continue;
}--n;
k=0;while(n)
{
if(n&1)
printf(\"%lld\n\", b[k]);++k;
n >>= 1;
}
}return 0;
}