結果
問題 | No.1988 Divisor Tiling |
ユーザー |
|
提出日時 | 2022-06-24 21:43:55 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,606 bytes |
コンパイル時間 | 181 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 72,192 KB |
最終ジャッジ日時 | 2024-11-08 17:37:37 |
合計ジャッジ時間 | 4,828 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 23 WA * 9 |
ソースコード
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: 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)