結果

問題 No.1988 Divisor Tiling
ユーザー siganaisiganai
提出日時 2022-06-25 19:00:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 772 ms
コンパイル使用メモリ 87,216 KB
実行使用メモリ 81,600 KB
最終ジャッジ日時 2023-08-09 11:51:23
合計ジャッジ時間 8,022 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
79,444 KB
testcase_01 AC 137 ms
79,388 KB
testcase_02 AC 138 ms
79,060 KB
testcase_03 AC 138 ms
79,440 KB
testcase_04 AC 137 ms
79,304 KB
testcase_05 AC 137 ms
79,520 KB
testcase_06 AC 133 ms
79,312 KB
testcase_07 AC 139 ms
79,440 KB
testcase_08 AC 138 ms
79,400 KB
testcase_09 AC 136 ms
79,508 KB
testcase_10 AC 138 ms
79,408 KB
testcase_11 AC 139 ms
79,456 KB
testcase_12 AC 137 ms
79,408 KB
testcase_13 AC 138 ms
79,424 KB
testcase_14 AC 137 ms
79,468 KB
testcase_15 AC 138 ms
79,308 KB
testcase_16 AC 140 ms
79,300 KB
testcase_17 AC 135 ms
79,468 KB
testcase_18 AC 144 ms
81,076 KB
testcase_19 AC 148 ms
80,776 KB
testcase_20 AC 147 ms
81,016 KB
testcase_21 AC 144 ms
80,756 KB
testcase_22 AC 147 ms
80,760 KB
testcase_23 AC 147 ms
80,924 KB
testcase_24 AC 145 ms
80,644 KB
testcase_25 AC 145 ms
80,860 KB
testcase_26 AC 147 ms
80,828 KB
testcase_27 AC 155 ms
80,748 KB
testcase_28 AC 154 ms
80,928 KB
testcase_29 AC 162 ms
81,600 KB
testcase_30 AC 161 ms
81,044 KB
testcase_31 AC 150 ms
80,840 KB
testcase_32 AC 138 ms
79,340 KB
testcase_33 AC 136 ms
79,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=998244353

import sys
input=sys.stdin.readline
n,h=map(int,input().split())
def divisor(n):
    sq = n**0.5
    border = int(sq)
    table = []
    bigs = []
    for small in range(1, border+1):
        if n%small == 0:
            table.append(small)
            big = n//small
            bigs.append(big)
    if border == sq:#nが平方数
        bigs.pop()
    table += reversed(bigs)
    return table
ta = divisor(n)
ans = [[0] * (n // h) for _ in range(h)]
if h & -h == h:
    i = j = 0
    k = 0
    while j < h:
        c = ta[k]
        while c:
            ans[j][i] = ta[k]
            c -= 1
            i += 1
            if i == n // h:
                i = 0
                j += 1
        k += 1
else:
    i = j = 0
    k = 0
    while i < n // h:
        c = ta[k]
        while c:
            ans[j][i] = ta[k]
            c -= 1
            j += 1
            if j == h:
                i += 1
                j = 0
        k += 1
for i in range(h):
    print(*ans[i])
0