#include #include #include #include #include #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int n, k; cin >> n >> k; auto m = (n + k - 1) / k; // m <= n m = max(m, (int)ceil(sqrt(n))); vector> a(m, vector(m, '.')); rep(i, m) a[i][i] = '#'; auto bk = m; rep(i, m) { rep(j, m) { if (a[i][j] == '#') continue; if (bk >= n) continue; int r_cnt = 0; rep(h, m) { if (a[h][j] == '#') r_cnt += 1; } int c_cnt = 0; rep(h, m) { if (a[i][h] == '#') c_cnt += 1; } if (r_cnt < k and c_cnt < k) { a[i][j] = '#'; bk += 1; } } } cout << m << endl; rep(i, m) { rep(j, m) { cout << a[i][j]; } cout << endl; } assert(bk == n); return 0; }