結果

問題 No.1988 Divisor Tiling
ユーザー k_o_pasturek_o_pasture
提出日時 2022-06-24 22:08:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 533 ms / 2,000 ms
コード長 699 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,616 KB
最終ジャッジ日時 2024-04-26 05:20:16
合計ジャッジ時間 20,963 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 502 ms
44,368 KB
testcase_01 AC 500 ms
44,232 KB
testcase_02 AC 495 ms
44,364 KB
testcase_03 AC 510 ms
44,364 KB
testcase_04 AC 509 ms
44,448 KB
testcase_05 AC 500 ms
44,360 KB
testcase_06 AC 496 ms
44,484 KB
testcase_07 AC 509 ms
44,496 KB
testcase_08 AC 511 ms
43,972 KB
testcase_09 AC 513 ms
44,348 KB
testcase_10 AC 515 ms
44,356 KB
testcase_11 AC 521 ms
44,616 KB
testcase_12 AC 522 ms
43,976 KB
testcase_13 AC 515 ms
43,852 KB
testcase_14 AC 514 ms
44,364 KB
testcase_15 AC 516 ms
44,232 KB
testcase_16 AC 512 ms
44,024 KB
testcase_17 AC 503 ms
44,236 KB
testcase_18 AC 515 ms
43,988 KB
testcase_19 AC 514 ms
43,976 KB
testcase_20 AC 478 ms
43,984 KB
testcase_21 AC 469 ms
44,108 KB
testcase_22 AC 502 ms
43,980 KB
testcase_23 AC 498 ms
44,488 KB
testcase_24 AC 501 ms
43,988 KB
testcase_25 AC 505 ms
44,236 KB
testcase_26 AC 506 ms
43,976 KB
testcase_27 AC 511 ms
43,976 KB
testcase_28 AC 512 ms
44,104 KB
testcase_29 AC 519 ms
44,104 KB
testcase_30 AC 529 ms
43,976 KB
testcase_31 AC 533 ms
44,108 KB
testcase_32 AC 516 ms
44,240 KB
testcase_33 AC 511 ms
44,360 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