#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair P; typedef bitset<16> BS; const ll MOD = 1E+09 + 7; const ll INF = 1E18; const int MAX_N = 1000; int N, K; char ans[MAX_N + 1][MAX_N + 1]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N >> K; int p = N / (K * K), r = N % (K * K); fill(ans[1], ans[N + 1], '.'); for (int c = 0; c < p; c++) { for (int i = 1; i <= K; i++) { for (int j = 1; j <= K; j++) { ans[c * K + i][c * K + j] = '#'; } } } int sr = 0; while (sr * sr <= r) { sr++; } sr--; for (int i = 1; i <= sr; i++) { for (int j = i; j <= sr; j++) { if (p * K + (i - 1) + sr + j <= N) { ans[(p - 1) * K + i][(p - 1) * K + j] = '#'; } } } /* for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n"; } } */ int M = p * K + sr; cout << M << "\n"; for (int i = 1; i <= M; i++) { for (int j = 1; j <= M; j++) { cout << ans[i][j]; } cout << "\n"; } return 0; }