結果

問題 No.1988 Divisor Tiling
ユーザー 👑 tamatotamato
提出日時 2022-06-24 21:40:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 86,568 KB
実行使用メモリ 77,748 KB
最終ジャッジ日時 2023-08-08 11:55:56
合計ジャッジ時間 5,024 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,080 KB
testcase_01 AC 72 ms
71,404 KB
testcase_02 AC 71 ms
71,236 KB
testcase_03 AC 75 ms
71,072 KB
testcase_04 AC 72 ms
71,268 KB
testcase_05 AC 73 ms
71,268 KB
testcase_06 AC 72 ms
71,100 KB
testcase_07 AC 71 ms
70,980 KB
testcase_08 AC 72 ms
71,072 KB
testcase_09 AC 73 ms
71,072 KB
testcase_10 AC 75 ms
71,352 KB
testcase_11 AC 74 ms
70,884 KB
testcase_12 AC 75 ms
71,052 KB
testcase_13 AC 73 ms
71,160 KB
testcase_14 AC 73 ms
71,200 KB
testcase_15 AC 74 ms
71,220 KB
testcase_16 AC 74 ms
71,068 KB
testcase_17 AC 74 ms
71,284 KB
testcase_18 AC 84 ms
76,504 KB
testcase_19 AC 84 ms
76,320 KB
testcase_20 AC 84 ms
76,432 KB
testcase_21 AC 84 ms
76,456 KB
testcase_22 AC 82 ms
76,180 KB
testcase_23 AC 84 ms
76,420 KB
testcase_24 AC 85 ms
76,516 KB
testcase_25 AC 84 ms
76,304 KB
testcase_26 AC 85 ms
76,548 KB
testcase_27 AC 91 ms
76,576 KB
testcase_28 AC 93 ms
76,488 KB
testcase_29 AC 104 ms
77,372 KB
testcase_30 AC 99 ms
77,748 KB
testcase_31 AC 91 ms
76,328 KB
testcase_32 AC 72 ms
71,244 KB
testcase_33 AC 72 ms
71,348 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