($N,$K)=glob<>; $M=($N-1)/$K+1|0; $M++while$M*$M<$N; print$M,$/; @A=map[('.')x$M,$/],1..$M; for$i(0..$M-1){ for$j(0..$M-1){ if($N--){ $A[$j][($i+$j)%$M]='#' }else{ goto z } } } z:print@$_ for@A