1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| #include "bits/stdc++.h"
using namespace std; using i64 = long long; using i128 = __int128;
constexpr i64 inf = 1E18;
i64 mul(i64 a, i64 b) { i128 res = static_cast<i128>(a) * b; if (res > inf) { return inf + 1; } return res; }
i64 power(i64 a, i64 b) { i64 res = 1; for (; b; b >>= 1, a = mul(a, a)) { if (b & 1) { res = mul(res, a); } } return res; }
vector<string> a = { "................................................................................", "................................................................................", "0000000.......1.2222222.3333333.4.....4.5555555.6666666.7777777.8888888.9999999.", "0.....0.......1.......2.......3.4.....4.5.......6.............7.8.....8.9.....9.", "0.....0.......1.......2.......3.4.....4.5.......6.............7.8.....8.9.....9.", "0.....0.......1.2222222.3333333.4444444.5555555.6666666.......7.8888888.9999999.", "0.....0.......1.2.............3.......4.......5.6.....6.......7.8.....8.......9.", "0.....0.......1.2.............3.......4.......5.6.....6.......7.8.....8.......9.", "0000000.......1.2222222.3333333.......4.5555555.6666666.......7.8888888.9999999.", "................................................................................" };
vector<string> b = { "............................................................", "00000.....1.22222.33333.4...4.55555.66666.77777.88888.99999.", "0...0.....1.....2.....3.4...4.5.....6.........7.8...8.9...9.", "0...0.....1.22222.33333.44444.55555.66666.....7.88888.99999.", "0...0.....1.2.........3.....4.....5.6...6.....7.8...8.....9.", "00000.....1.22222.33333.....4.55555.66666.....7.88888.99999.", "............................................................", "............................................................", "............................................................", "............................................................" };
vector<string> c = { "................................", "................................", "........IIIIIII.N.....N.FFFFFFF.", "...........I....NN....N.F.......", "=======....I....N.N...N.F.......", "...........I....N..N..N.FFFFFFF.", "=======....I....N...N.N.F.......", "...........I....N....NN.F.......", "........IIIIIII.N.....N.F.......", "................................" };
void solve() { i64 A, B; scanf("%lld^{%lld}", &A, &B); int N = 10; i64 res = power(A, B); vector<string> ans(N); for (int i = 0; i < N; i++) { ans[i] += "."; } auto get = [&](const int &l, const int &len, const vector<string> &s) { for (int i = 0; i < N; i++) { ans[i] += s[i].substr(l, len); }
};
string SA = to_string(A); string SB = to_string(B); for (auto &x : SA) { int y = x - '0'; get(y * 8, 8, a); } for (auto &x : SB) { int y = x - '0'; get(y * 6, 6, b); } get(0, 8, c); if (res > inf) { get(8, 24, c); } else { string t = to_string(res); for (auto &x : t) { int y = x - '0'; get(y * 8, 8, a); } } for (auto &x : ans) { cout << x << '\n'; } }
int main() {
int t; scanf("%d", &t); while (t--) { solve(); }
return 0; }
|