local mfl, mce = math.floor, math.ceil local n, k = io.read("*n", "*n") local rep = math.floor(n / (k * k)) local rem = n - rep * k * k local remsize = math.ceil(math.sqrt(rem)) local size = k * rep + remsize print(size) for i = 1, size do local bi = mce(i / k) for j = 1, size do local bj = mce(j / k) if bi == bj then if 0 < n then io.write("#") n = n - 1 else io.write(".") end else io.write(".") end end io.write("\n") end