結果

問題 No.2339 Factorial Paths
ユーザー hir355hir355
提出日時 2023-06-02 22:42:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 814 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 108,820 KB
最終ジャッジ日時 2023-08-28 04:55:21
合計ジャッジ時間 11,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,528 KB
testcase_01 AC 74 ms
71,220 KB
testcase_02 AC 74 ms
71,424 KB
testcase_03 AC 73 ms
71,076 KB
testcase_04 AC 71 ms
71,536 KB
testcase_05 AC 73 ms
71,364 KB
testcase_06 AC 71 ms
71,072 KB
testcase_07 AC 74 ms
71,524 KB
testcase_08 AC 80 ms
76,316 KB
testcase_09 AC 84 ms
76,744 KB
testcase_10 AC 91 ms
77,444 KB
testcase_11 AC 96 ms
79,000 KB
testcase_12 AC 98 ms
79,292 KB
testcase_13 AC 112 ms
81,544 KB
testcase_14 AC 136 ms
83,540 KB
testcase_15 AC 197 ms
91,116 KB
testcase_16 AC 277 ms
98,800 KB
testcase_17 AC 332 ms
105,360 KB
testcase_18 AC 346 ms
107,536 KB
testcase_19 AC 356 ms
107,744 KB
testcase_20 AC 352 ms
107,716 KB
testcase_21 AC 347 ms
108,820 KB
testcase_22 AC 359 ms
108,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 1:
    print(1, 1)
    print('.')
    exit(0)
l = []
st = [n]
h, w = 1, 1
while st:
    p = st.pop()
    if p == 1:
        continue
    st.append(p // 2)
    st.append((p + 1) // 2)
    if h < w:
        l.append((p // 2, (p + 1) // 2))
        h += p // 2 + 1
        w += (p + 1) // 2 + 1
    else:
        l.append(((p + 1) // 2, p // 2))
        w += p // 2
        h += (p + 1) // 2
s = [['#'] * w for _ in range(h)]
p, q = 0, 0
for x, y in l:
    for j in range(p, p + x + 1):
        for k in range(q, q + y + 1):
            s[j][k] = '.'
    p += x
    q += y
print(h, w)
for row in s:
    print(*row, sep='')
0