($n,$k)=glob<>; $m=int(($n-1)/$k)+1; print$m,$/; for(0..$n-1){ while($a[$y][$x]){ $x=($x+1)%$m; } $a[$y][$x]=1; $x=($x+1)%$m; $y=($y+1)%$m; } for$y(0..$m-1){ for$x(0..$m-1){ if($a[$y][$x]){ print'#'; }else{ print'.'; } } print$/; }