結果

問題 No.1988 Divisor Tiling
ユーザー tamatotamato
提出日時 2022-06-24 21:40:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 74,736 KB
最終ジャッジ日時 2024-04-26 04:54:11
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,436 KB
testcase_01 AC 36 ms
53,136 KB
testcase_02 AC 37 ms
53,268 KB
testcase_03 AC 37 ms
52,840 KB
testcase_04 AC 37 ms
52,816 KB
testcase_05 AC 37 ms
52,744 KB
testcase_06 AC 36 ms
53,276 KB
testcase_07 AC 36 ms
52,320 KB
testcase_08 AC 38 ms
53,684 KB
testcase_09 AC 39 ms
53,792 KB
testcase_10 AC 39 ms
53,480 KB
testcase_11 AC 38 ms
53,008 KB
testcase_12 AC 38 ms
53,216 KB
testcase_13 AC 38 ms
53,984 KB
testcase_14 AC 39 ms
54,000 KB
testcase_15 AC 39 ms
54,512 KB
testcase_16 AC 39 ms
55,040 KB
testcase_17 AC 39 ms
53,340 KB
testcase_18 AC 48 ms
65,044 KB
testcase_19 AC 49 ms
64,512 KB
testcase_20 AC 49 ms
64,488 KB
testcase_21 AC 48 ms
65,172 KB
testcase_22 AC 48 ms
63,940 KB
testcase_23 AC 49 ms
64,704 KB
testcase_24 AC 48 ms
64,472 KB
testcase_25 AC 50 ms
65,248 KB
testcase_26 AC 51 ms
65,808 KB
testcase_27 AC 56 ms
68,588 KB
testcase_28 AC 58 ms
69,416 KB
testcase_29 AC 64 ms
73,256 KB
testcase_30 AC 61 ms
74,736 KB
testcase_31 AC 53 ms
68,712 KB
testcase_32 AC 36 ms
53,296 KB
testcase_33 AC 37 ms
54,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353


def main():
    import sys
    input = sys.stdin.readline

    X = {6: 3, 28: 7, 496: 31, 8128: 127}

    N, H = map(int, input().split())
    x = X[N]
    flipped = 0
    if H % x == 0:
        flipped = 1
        H = N // H
    W = N // H
    y = W // x
    div = []
    for d in range(N-1, 0, -1):
        if N % d == 0:
            div.append(d)
    ans = [[0] * W for _ in range(H)]
    h = 0
    div2 = []
    for d in div:
        if d % W == 0:
            for hh in range(h, h + d // W):
                for w in range(W):
                    ans[hh][w] = d
            h += d // W
        else:
            div2.append(d)
    w = 0
    for d in div2:
        for _ in range(d):
            ans[-1][w] = d
            w += 1

    if flipped:
        ans2 = [[0] * H for _ in range(W)]
        for h in range(H):
            for w in range(W):
                ans2[w][h] = ans[h][w]
        ans = ans2
        H = W
    for h in range(H):
        print(*ans[h])


if __name__ == '__main__':
    main()
0