Decompose integer into sum of squares by Songmu

$c[0]=[];for$i(1..300){$j=int sqrt $i;my@t;push@t,[sort{$b<=>$a}$_,@{$c[$i-$_**2]}]for 1..$j;@t=sort{o(@$a)<=>o(@$b)}@t;my@r;@r=@{$t[0]};$c[$i]=\@r;print"$i: ".(join" ",@r)."
"}sub o{$u=$#_*50;$u+=x(@_)-n(@_);$u}sub x{$k=0;for(@_){$k=$_ if$_>$i}$k}sub n{$k=20;for(@_){$k=$_ if$_<$i}}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page