local n, k = io.read("*n", "*n") local rem = n local sz = 0 while true do if rem <= k * k then local tmp = math.floor(math.sqrt(rem)) if tmp * tmp < rem then tmp = tmp + 1 end sz = sz + tmp break else rem = rem - k * k sz = sz + k end end print(sz) local usedline = 0 rem = n while 0 < rem do if k * k <= rem then for i = 1, k do for j = 1, sz do if usedline < j and j <= usedline + k then io.write("#") else io.write(".") end end io.write("\n") end usedline = usedline + k rem = rem - k * k else local remline = sz - usedline for i = 1, remline do for j = 1, sz do if usedline < j and j <= usedline + remline and 0 < rem then io.write("#") rem = rem - 1 else io.write(".") end end io.write("\n") end usedline = sz end end