# cheat??!?! $x=<>; while($x-=$%*$%){ $%=$x-32?sqrt$x:4; push@a,$%; } for(reverse@a){ if($_%2){ print"01"x($_/2),0; }else{ push@E,$_; } } while($_=pop@E){ print"01"x($_/2); if($_=shift@E){ print"10"x($_/2); } }