結果

問題 No.642 Two Operations No.1
ユーザー qibqib
提出日時 2023-05-03 20:18:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 87,188 KB
実行使用メモリ 71,544 KB
最終ジャッジ日時 2023-08-14 03:00:05
合計ジャッジ時間 2,675 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,444 KB
testcase_01 AC 71 ms
71,452 KB
testcase_02 AC 69 ms
71,380 KB
testcase_03 AC 72 ms
71,280 KB
testcase_04 AC 70 ms
71,348 KB
testcase_05 AC 70 ms
71,412 KB
testcase_06 AC 71 ms
71,480 KB
testcase_07 AC 70 ms
71,348 KB
testcase_08 AC 69 ms
71,288 KB
testcase_09 AC 70 ms
71,348 KB
testcase_10 AC 70 ms
71,544 KB
testcase_11 AC 70 ms
71,432 KB
testcase_12 AC 70 ms
71,120 KB
testcase_13 AC 71 ms
71,484 KB
testcase_14 AC 71 ms
71,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n =int(input())

dp = {}
dp[1] = 0
def answer(x):
  if not dp.get(x, None) is None:
    return dp[x]
  else:
    if x % 2 == 0:
      ans = answer(x // 2) + 1
    else:
      ans = answer(x + 1) + 1

    dp[x] = ans
    return ans

print(answer(n))
0