f | from math import ceil | f | from math import ceil |
| (n, size) = eval(input()) | | (n, size) = eval(input()) |
n | length = len(str(n * n)) | n | max_len = len(str(n * n)) |
| number = len(str(n)) | | num_len = len(str(n)) |
| split_str = '=' * size | | split_str = '=' * size |
n | string_len = length + number * 2 + 9 | n | string_len = max_len + num_len * 2 + 9 |
| string_len = (size + 3) // string_len | | string_len = (size + 3) // string_len |
| rows = ceil(n / string_len) | | rows = ceil(n / string_len) |
| print(split_str) | | print(split_str) |
| strings = [] | | strings = [] |
| for i in range(1, n + 1): | | for i in range(1, n + 1): |
| for j in range(1, n + 1): | | for j in range(1, n + 1): |
t | string = f'{i:>{number}} * {j:<{number}} = {i * j:<{length}} ' | t | string = f'{i:>{num_len}} * {j:<{num_len}} = {i * j:<{max_len}} ' |
| strings.append(string) | | strings.append(string) |
| for s in range(rows): | | for s in range(rows): |
| for a in range(n): | | for a in range(n): |
| for b in range(string_len): | | for b in range(string_len): |
| if s * n * string_len + b * n + a >= len(strings): | | if s * n * string_len + b * n + a >= len(strings): |
| continue | | continue |
| if b != 0: | | if b != 0: |
| print('| ', end='') | | print('| ', end='') |
| print(strings[s * n * string_len + b * n + a], end='') | | print(strings[s * n * string_len + b * n + a], end='') |
| print() | | print() |
| print(split_str) | | print(split_str) |