結果

問題 No.883 ぬりえ
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-24 01:48:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 86,784 KB
最終ジャッジ日時 2023-10-21 15:30:28
合計ジャッジ時間 2,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
53,396 KB
testcase_01 AC 32 ms
53,396 KB
testcase_02 AC 32 ms
53,396 KB
testcase_03 AC 34 ms
53,396 KB
testcase_04 AC 31 ms
53,396 KB
testcase_05 AC 31 ms
53,396 KB
testcase_06 AC 33 ms
53,396 KB
testcase_07 AC 31 ms
53,396 KB
testcase_08 AC 32 ms
53,396 KB
testcase_09 AC 30 ms
53,396 KB
testcase_10 AC 31 ms
53,396 KB
testcase_11 AC 30 ms
53,396 KB
testcase_12 AC 30 ms
53,396 KB
testcase_13 AC 30 ms
53,396 KB
testcase_14 AC 37 ms
58,908 KB
testcase_15 AC 107 ms
86,784 KB
testcase_16 AC 68 ms
79,816 KB
testcase_17 AC 62 ms
77,448 KB
testcase_18 AC 36 ms
58,928 KB
testcase_19 AC 34 ms
53,400 KB
testcase_20 AC 32 ms
53,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
if N == K * (K + 1):
    print(K + 1)
    for i in range(K+1):
        for j in range(K+1):
            if i == j:
                print(".", end="")
            else:
                print("#", end="")
        print()
    exit()


d, m = divmod(N, K * K)
r = 0
while True:
    if r * r >= m:
        break
    r += 1

size = K * d + r
res = [[0] * size for _ in range(size)]
p = 0
for _ in range(d):
    for i in range(K):
        for j in range(K):
            res[p + i][p + j] = N
            N = max(0, N-1)
    p += K

for i in range(r):
    for j in range(r):
        res[p + i][p + j] = N
        N = max(0, N-1)

print(size)
for r in res:
    for i in r:
        if i:
            print("#", end="")
        else:
            print(".", end="")
    print()
0