結果

問題 No.1988 Divisor Tiling
ユーザー kyskys
提出日時 2022-06-24 21:40:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,567 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,604 KB
実行使用メモリ 73,492 KB
最終ジャッジ日時 2024-04-26 04:54:05
合計ジャッジ時間 5,164 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,632 KB
testcase_01 AC 39 ms
53,432 KB
testcase_02 AC 39 ms
52,628 KB
testcase_03 AC 39 ms
53,680 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 40 ms
53,484 KB
testcase_07 AC 39 ms
52,532 KB
testcase_08 AC 38 ms
53,628 KB
testcase_09 AC 41 ms
54,068 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 40 ms
53,336 KB
testcase_17 AC 39 ms
53,572 KB
testcase_18 AC 53 ms
64,760 KB
testcase_19 AC 52 ms
65,420 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 60 ms
72,244 KB
testcase_31 AC 54 ms
66,116 KB
testcase_32 AC 37 ms
53,148 KB
testcase_33 AC 37 ms
53,232 KB
権限があれば一括ダウンロードができます

ソースコード

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]

N, H = liinput()
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:
            while ctr * W < k:
                for j in range(W):
                    ans[ctr][j] = k
                ctr += 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:
            while ctr * H < k:
                for j in range(H):
                    ans[j][ctr] = k
                ctr += 1
        else:
            j = 0
            while j < k:
                ans[ctr2][-1] = k
                ctr2 += 1
                j += 1

for a in ans:
    print(*a)
0