結果
| 問題 |
No.1988 Divisor Tiling
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-24 21:45:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,830 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 65,664 KB |
| 最終ジャッジ日時 | 2024-11-08 17:39:21 |
| 合計ジャッジ時間 | 6,353 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | AC * 14 WA * 10 RE * 8 |
ソースコード
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)