結果

問題 No.1988 Divisor Tiling
ユーザー kyskys
提出日時 2022-06-24 21:45:35
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,830 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,360 KB
実行使用メモリ 67,340 KB
最終ジャッジ日時 2024-04-26 04:58:18
合計ジャッジ時間 6,190 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 40 ms
53,352 KB
testcase_09 AC 39 ms
53,140 KB
testcase_10 AC 40 ms
52,732 KB
testcase_11 AC 41 ms
53,340 KB
testcase_12 AC 40 ms
53,208 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 40 ms
52,912 KB
testcase_18 AC 49 ms
63,024 KB
testcase_19 AC 49 ms
63,404 KB
testcase_20 AC 48 ms
62,980 KB
testcase_21 AC 47 ms
63,924 KB
testcase_22 AC 51 ms
62,712 KB
testcase_23 AC 49 ms
62,976 KB
testcase_24 AC 49 ms
63,176 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 53 ms
62,976 KB
testcase_32 RE -
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def iinput(): return int(input())
def sinput(): return input().rstrip()
def i0input(): return int(input()) - 1
def linput(): return list(input().split())
def liinput(): return list(map(int, input().split()))
def miinput(): return map(int, input().split())
def li0input(): return list(map(lambda x: int(x) - 1, input().split()))
def mi0input(): return map(lambda x: int(x) - 1, input().split())
INF = 10**20
MOD = 1000000007

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def solve(N, H):
    W = N // H
    ans = [[0] * W for _ in [0] * H]

    if W > H:
        ctr = 0
        ctr2 = 0
        for k in make_divisors(N)[::-1][1:]:
            if k >= W:
                i = 0
                while i * W < k:
                    for j in range(W):
                        ans[ctr][j] = k
                    ctr += 1
                    i += 1
            else:
                j = 0
                while j < k:
                    ans[-1][ctr2] = k
                    ctr2 += 1
                    j += 1
    else:
        ctr = 0
        ctr2 = 0
        for k in make_divisors(N)[::-1][1:]:
            if k >= H:
                i = 0
                while i * H < k:
                    for j in range(H):
                        ans[j][ctr] = k
                    ctr += 1
                    i += 1
            else:
                j = 0
                while j < k:
                    ans[ctr2][-1] = k
                    ctr2 += 1
                    j += 1

    for a in ans:
        print(*a)

N, H = liinput()

solve(N, 16)
0