#include using namespace std; using ll = long long; int calc(int n, int K) { if (n == 0) return 0; if (n >= K * K) return calc(n - K * K, K) + K; int res = 0; for (int i = 1; i <= K; i++) { if (n <= i * i) { res = i; break; } } return res; } bool judge(vector& ans, int n, int K) { int m = ans.size(); for (int i = 0; i < m; i++) { int tmp = 0; for (int j = 0; j < m; j++) { tmp += (ans[i][j] == '#'); } if (tmp > K) return false; } int cnt = 0; for (int j = 0; j < m; j++) { int tmp = 0; for (int i = 0; i < m; i++) { tmp += (ans[i][j] == '#'); cnt += (ans[i][j] == '#'); } if (tmp > K) return false; } return (cnt == n); } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, K; cin >> n >> K; int m = calc(n, K); cout << m << "\n"; vector ans(m, string(m, '.')); int rest = n; for (int i = 0; i < m; i++) { int ii = i / K; for (int j = 0; j < m; j++) { int jj = j / K; if (ii == jj && rest > 0) { rest--; ans[i][j] = '#'; } } cout << ans[i] << "\n"; } assert(judge(ans, n, K)); return 0; }