#include #include #include #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 unsigned long long ul; typedef unsigned int ui; typedef long double ld; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef complex Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair P; typedef pair LDP; typedef pair LP; typedef vector vec; typedef vector> mat; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } //#define int long long void solve() { int n, k; cin >> n >> k; int cnt = n / (k * k), amari = n % (k * k), amarihen; rep1(i, k) { if(i * i >= amari) { amarihen = i; break; } } if(k * k * cnt == n) { amarihen = 0; } int m = k * cnt + amarihen; cout << m << endl; char a[1010][1010]; rep(i, m) { rep(j, m) { if(i / k == j / k) { a[i][j] = '#'; } else { a[i][j] = '.'; } } } int muda = k * k * cnt + amarihen * amarihen - n; int i = 0, j = 0; while(muda > 0) { a[i][j] = '.'; muda --; if(j < k - 1) { j ++; } else { i ++; j = 0; } } rep(i, m) { rep(j, m) { cout << a[i][j]; } cout << endl; } } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //init(); solve(); //cout << "finish" << endl; return 0; }