結果

問題 No.566 だいたい完全二分木
ユーザー kohei2019kohei2019
提出日時 2022-02-11 13:00:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 306 bytes
コンパイル時間 725 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 78,752 KB
最終ジャッジ日時 2023-09-09 14:07:10
合計ジャッジ時間 2,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,412 KB
testcase_01 AC 70 ms
71,356 KB
testcase_02 AC 71 ms
71,084 KB
testcase_03 AC 72 ms
71,472 KB
testcase_04 AC 71 ms
71,408 KB
testcase_05 AC 70 ms
71,308 KB
testcase_06 AC 71 ms
71,284 KB
testcase_07 AC 74 ms
71,304 KB
testcase_08 AC 83 ms
75,640 KB
testcase_09 AC 94 ms
76,812 KB
testcase_10 AC 106 ms
78,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

K = int(input())

ans = []
def dfs(t):
    ans.append(t)
    s = list(bin(t))
    s.reverse()
    i0 = 0
    for i in range(len(s)):
        if s[i] == '1':
            i0 = i
            break
    if i0 == 0:
        return
    dfs(t+2**(i-1))
    dfs(t-2**(i-1))

dfs(2**(K-1))
print(*(ans[:-3]+[1,3,2]))
0