結果

問題 No.1988 Divisor Tiling
ユーザー EguyEguy
提出日時 2022-06-24 21:44:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 82,956 KB
実行使用メモリ 73,076 KB
最終ジャッジ日時 2024-04-26 04:56:56
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,980 KB
testcase_01 AC 37 ms
52,632 KB
testcase_02 AC 38 ms
53,260 KB
testcase_03 AC 37 ms
52,852 KB
testcase_04 AC 37 ms
53,944 KB
testcase_05 AC 37 ms
52,936 KB
testcase_06 AC 38 ms
53,680 KB
testcase_07 AC 40 ms
53,396 KB
testcase_08 AC 40 ms
54,980 KB
testcase_09 AC 39 ms
53,916 KB
testcase_10 AC 39 ms
53,632 KB
testcase_11 AC 39 ms
53,624 KB
testcase_12 AC 38 ms
53,328 KB
testcase_13 AC 39 ms
53,992 KB
testcase_14 AC 40 ms
55,144 KB
testcase_15 AC 39 ms
54,668 KB
testcase_16 AC 39 ms
53,792 KB
testcase_17 AC 41 ms
54,192 KB
testcase_18 AC 51 ms
63,976 KB
testcase_19 AC 50 ms
65,772 KB
testcase_20 AC 51 ms
66,732 KB
testcase_21 AC 49 ms
64,712 KB
testcase_22 AC 51 ms
65,112 KB
testcase_23 AC 50 ms
65,648 KB
testcase_24 AC 50 ms
65,796 KB
testcase_25 AC 50 ms
66,156 KB
testcase_26 AC 53 ms
66,440 KB
testcase_27 AC 58 ms
69,224 KB
testcase_28 AC 57 ms
69,496 KB
testcase_29 AC 65 ms
73,076 KB
testcase_30 AC 60 ms
72,868 KB
testcase_31 AC 55 ms
68,036 KB
testcase_32 AC 38 ms
53,472 KB
testcase_33 AC 38 ms
52,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
sys.setrecursionlimit(1000000)
INF = 1 << 100
mod = 1000000007
#mod = 998244353
input = lambda: sys.stdin.readline().rstrip()
li = lambda: list(map(int, input().split()))

def get_divisors(x: int) -> list:
    divisors = []
    for i in range(1, x+1):
        if i * i > x:
            break
        if x % i == 0:
            divisors.append(i)
            if x // i != i:
                divisors.append(x // i)
    return divisors

N, H = li()
W = N // H
flg = 0
if H > W:
    H, W = W, H
    flg = 1

divs = get_divisors(N)
divs = sorted(divs, reverse=1)[1:]
ans = [[0] * W for _ in range(H)]
idx = 0
rest = [i for i in divs]

for h in range(H):
    for w in range(W):
        ans[h][w] = divs[idx]
        rest[idx] -= 1
        if not rest[idx]:
            idx += 1

if flg:
    def rotate_clockwise(A):
        return list(zip(*(A[::-1])))
    ans = rotate_clockwise(ans)

for a in ans:
    print(*a)
0