結果

問題 No.887 Collatz
ユーザー lam6er
提出日時 2025-03-20 20:18:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 300 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,752 KB
実行使用メモリ 53,744 KB
最終ジャッジ日時 2025-03-20 20:18:48
合計ジャッジ時間 2,158 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
current = n
max_val = current
steps = 0

while current != 1:
    if current % 2 == 0:
        next_val = current // 2
    else:
        next_val = 3 * current + 1
    if next_val > max_val:
        max_val = next_val
    steps += 1
    current = next_val

print(steps)
print(max_val)
0