fork download
  1. while(<>){
  2. $_= sprintf "0%b", $_;
  3. $_=reverse $_;
  4. while ( s/(1{2,})0/"-1".(0 x (-1+length($1))).1/e ){;}
  5. s/0$//;
  6. s/0|1/$& /g;
  7. @_=reverse (split/ /,$_);
  8. print "@_\n";
  9. }
Success #stdin #stdout 0s 3564KB
stdin
3
4
5
6
7
31
stdout
1 0 -1
1 0 0
1 0 1
1 0 -1 0
1 0 0 -1
1 0 0 0 0 -1