結果

問題 No.1988 Divisor Tiling
ユーザー k_o_pasturek_o_pasture
提出日時 2022-06-24 22:08:03
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 919 ms
コンパイル使用メモリ 10,820 KB
実行使用メモリ 30,288 KB
最終ジャッジ日時 2023-08-08 12:24:06
合計ジャッジ時間 9,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
29,528 KB
testcase_01 AC 132 ms
29,688 KB
testcase_02 AC 131 ms
29,632 KB
testcase_03 AC 134 ms
29,532 KB
testcase_04 AC 133 ms
29,616 KB
testcase_05 AC 133 ms
29,532 KB
testcase_06 AC 134 ms
29,664 KB
testcase_07 AC 135 ms
29,692 KB
testcase_08 AC 136 ms
29,588 KB
testcase_09 AC 136 ms
29,596 KB
testcase_10 AC 132 ms
29,600 KB
testcase_11 AC 131 ms
29,692 KB
testcase_12 AC 132 ms
29,604 KB
testcase_13 AC 132 ms
29,696 KB
testcase_14 AC 133 ms
29,588 KB
testcase_15 AC 134 ms
29,684 KB
testcase_16 AC 134 ms
29,732 KB
testcase_17 AC 133 ms
29,728 KB
testcase_18 AC 140 ms
30,288 KB
testcase_19 AC 144 ms
29,984 KB
testcase_20 AC 142 ms
29,832 KB
testcase_21 AC 143 ms
29,928 KB
testcase_22 AC 141 ms
29,940 KB
testcase_23 AC 139 ms
29,804 KB
testcase_24 AC 142 ms
29,780 KB
testcase_25 AC 142 ms
29,996 KB
testcase_26 AC 143 ms
29,892 KB
testcase_27 AC 141 ms
29,896 KB
testcase_28 AC 141 ms
29,916 KB
testcase_29 AC 143 ms
29,932 KB
testcase_30 AC 147 ms
29,840 KB
testcase_31 AC 155 ms
30,020 KB
testcase_32 AC 132 ms
29,544 KB
testcase_33 AC 131 ms
29,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
from math import sqrt

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 = map(int,input().split())

divs = make_divisors(N)[:-1]
# print(divs)
if ~ H in divs:
	print(-1)
	exit()

tiles = []
for div in divs:
	for _ in range(div):
		tiles.append(div)
# print(tiles)

if H > sqrt(N):
	I = N//H
else:
	I = H

tiles = np.array(tiles)
tiles = tiles.reshape(I,N//I)
if H > sqrt(N):
	tiles = tiles.T
for tile in tiles:
	print(*list(tile))
0