#ifndef LOCAL #include using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif void solve() { int N, K; cin >> N >> K; auto check = [&](int L) -> bool { int Lq = L / K, Lr = L % K; return K * K * Lq + Lr * Lr <= N; }; int lo = 1, hi = 1001; while (hi - lo > 1) { int mi = (lo + hi) >> 1; (check(mi) ? lo : hi) = mi; } cout << lo << endl; vector ans(lo, string(lo, '.')); int cur = 0; [&]() -> void { while (N) { for (int i = cur; i < min(lo, cur + K); i++) { for (int j = cur; j < min(lo, cur + K); j++) { ans[i][j] = '#'; N--; if (!N) return; } } cur += K; } }(); for (int i = 0; i < lo; i++) cout << ans[i] << "\n"; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }