結果

問題 No.1988 Divisor Tiling
ユーザー siganaisiganai
提出日時 2022-06-25 19:00:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 78,788 KB
最終ジャッジ日時 2024-04-27 06:57:50
合計ジャッジ時間 4,308 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
65,964 KB
testcase_01 AC 57 ms
66,088 KB
testcase_02 AC 57 ms
64,788 KB
testcase_03 AC 57 ms
64,532 KB
testcase_04 AC 56 ms
64,200 KB
testcase_05 AC 57 ms
64,440 KB
testcase_06 AC 57 ms
64,564 KB
testcase_07 AC 57 ms
64,888 KB
testcase_08 AC 60 ms
65,680 KB
testcase_09 AC 58 ms
64,796 KB
testcase_10 AC 58 ms
64,780 KB
testcase_11 AC 59 ms
66,104 KB
testcase_12 AC 59 ms
65,928 KB
testcase_13 AC 59 ms
65,464 KB
testcase_14 AC 58 ms
66,180 KB
testcase_15 AC 59 ms
65,944 KB
testcase_16 AC 60 ms
65,348 KB
testcase_17 AC 60 ms
65,452 KB
testcase_18 AC 67 ms
70,368 KB
testcase_19 AC 68 ms
71,688 KB
testcase_20 AC 70 ms
70,932 KB
testcase_21 AC 67 ms
71,420 KB
testcase_22 AC 68 ms
71,936 KB
testcase_23 AC 66 ms
71,368 KB
testcase_24 AC 68 ms
70,344 KB
testcase_25 AC 68 ms
71,060 KB
testcase_26 AC 72 ms
71,700 KB
testcase_27 AC 73 ms
74,844 KB
testcase_28 AC 75 ms
74,732 KB
testcase_29 AC 92 ms
78,236 KB
testcase_30 AC 87 ms
78,788 KB
testcase_31 AC 71 ms
72,740 KB
testcase_32 AC 57 ms
65,524 KB
testcase_33 AC 57 ms
65,896 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