#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) ? hi : lo) = mi; } cout << hi << endl; vector ans(hi, string(hi, '.')); int cur = 0; [&]() -> void { while (N) { for (int i = cur; i < min(hi, cur + K); i++) { for (int j = cur; j < min(hi, cur + K); j++) { ans[i][j] = '#'; N--; if (!N) return; } } cur += K; } }(); for (int i = 0; i < hi; 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(); } }