#include <iostream> #include <vector> #include <string> #include <cassert> #include <cstdint> using i64 = std::int64_t; i64 ways(i64 N, i64 M) { return 1LL * N * (N - 1) / 2 * M * (M - 1) / 2; } int main() { std::ios_base::sync_with_stdio(false); i64 K; std::cin >> K; std::vector<std::pair<int, int>> pairs; auto tmp_K = K; while (K > 0) { int start = 2020; int end = 1; int sign = -1; std::pair<int, int> who{-1, -1}; bool found = false; for (int N = start; N != end; N += sign) { int start_2 = N; if (K <= 1'000'000) { start_2 = 4; } for (int M = start_2; M != end; M += sign) { if (ways(N, M) <= K && K > 0 && (who.first == -1 || K - ways(N, M) < K - ways(who.first, who.second))) { // pairs.emplace_back(N, M); //// std::cerr << ways(N, M) << " " << K << "\n"; // K -= ways(N, M); //// found = true; // break; // std::cerr << "new K = " << K << "\n"; who = {N, M}; } } } pairs.push_back(who); K -= ways(who.first, who.second); } const int H = 2025; const int W = 2025; // // std::cerr << 1LL * 750 * 750 * 1499 * 1499 << "\n"; // // std::cerr << pairs.size() << "\n"; // for (const auto& [x, y] : pairs) { // std::cerr << x << " " << y << "\n"; // } // // return 0; std::vector<std::string> mat(H, std::string(W, '.')); int line = 0, col = 0; int max_line_before = 0; for (auto& [x, y] : pairs) { std::vector<std::vector<int>> sum(H + 2, std::vector<int>(W + 1)); for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { // std::cerr << i << " " << j << "\n"; sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1]; if (mat[i - 1][j - 1] == '#') { sum[i][j]++; } } } bool found = false; for (int rep = 0; rep < 2 && !found; rep++) { for (int i = x + 2; i <= H && !found; i++) { for (int j = y + 2; j <= W && !found; j++) { int s = sum[i][j] - sum[i - x - 2][j] - sum[i][j - y - 2] + sum[i - x - 2][j - y - 2]; if (s == 0) { // std::cerr << "found corners\n"; for (int k = 0; k < x; k++) { for (int w = 0; w < y; w++) { mat[i - x + k- 1][j - y + w - 1] = '#'; } } found = true; } } } std::swap(x, y); } if (!found) { assert(false); } } std::cout << H << " " << W << "\n"; for (const std::string& S : mat) { std::cout << S << "\n"; } return 0; }