結果

問題 No.1988 Divisor Tiling
ユーザー EguyEguy
提出日時 2022-06-24 21:44:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 77,148 KB
最終ジャッジ日時 2023-08-08 11:58:57
合計ジャッジ時間 4,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,008 KB
testcase_01 AC 72 ms
71,208 KB
testcase_02 AC 74 ms
71,344 KB
testcase_03 AC 78 ms
71,076 KB
testcase_04 AC 71 ms
71,280 KB
testcase_05 AC 72 ms
71,452 KB
testcase_06 AC 72 ms
71,296 KB
testcase_07 AC 73 ms
70,876 KB
testcase_08 AC 72 ms
71,312 KB
testcase_09 AC 74 ms
71,008 KB
testcase_10 AC 73 ms
71,004 KB
testcase_11 AC 73 ms
71,200 KB
testcase_12 AC 74 ms
71,404 KB
testcase_13 AC 74 ms
71,004 KB
testcase_14 AC 74 ms
71,048 KB
testcase_15 AC 74 ms
71,048 KB
testcase_16 AC 74 ms
71,020 KB
testcase_17 AC 75 ms
71,012 KB
testcase_18 AC 84 ms
76,540 KB
testcase_19 AC 84 ms
76,440 KB
testcase_20 AC 87 ms
76,608 KB
testcase_21 AC 84 ms
76,496 KB
testcase_22 AC 84 ms
76,400 KB
testcase_23 AC 84 ms
76,444 KB
testcase_24 AC 85 ms
76,560 KB
testcase_25 AC 88 ms
76,280 KB
testcase_26 AC 88 ms
76,548 KB
testcase_27 AC 92 ms
76,724 KB
testcase_28 AC 95 ms
76,568 KB
testcase_29 AC 102 ms
77,148 KB
testcase_30 AC 95 ms
76,640 KB
testcase_31 AC 87 ms
76,296 KB
testcase_32 AC 73 ms
71,408 KB
testcase_33 AC 73 ms
71,372 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