$K=<>; for$a(1..30){ for$b(0..30-$a){ if($a*($a-1)/2*2**$b==$K){ exit!print$a+$b,"\n@{[(1)x$a,(0)x$b]}\n" } } }