結果

問題 No.642 Two Operations No.1
ユーザー tnodinotnodino
提出日時 2022-05-06 18:49:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 296 bytes
コンパイル時間 777 ms
コンパイル使用メモリ 10,608 KB
実行使用メモリ 280,436 KB
最終ジャッジ日時 2023-09-19 07:57:27
合計ジャッジ時間 5,057 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 17 ms
7,900 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 16 ms
7,812 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import setrecursionlimit
setrecursionlimit(10**6)

def dfs(x):
    if x in dic:
        return dic[x]
    if N % 2 == 0:
        dic[x] = dfs(x//2) + 1
        return dic[x]
    else:
        dic[x] = dfs(x-1) + 1
        return dic[x]

N = int(input())
dic = {}
dic[1] = 0
print(dfs(N))
0