結果

問題 No.887 Collatz
コンテスト
ユーザー touma6174
提出日時 2026-10-30 17:10:16
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 31 ms / 2,000 ms
+ 223µs
コード長 507 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 76 ms
コンパイル使用メモリ 64,432 KB
実行使用メモリ 53,600 KB
最終ジャッジ日時 2026-10-30 17:10:20
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://github.com/touma6174/competitive-programming-library.git
def yn(x: bool) -> None:
    print("Yes" if x else "No")
def YN(x: bool) -> None:
    print("YES" if x else "NO")
dr: list[int] = [-1, 0, 0, 1]; dc: list[int] = [0, -1, 1, 0]
dr8: list[int] = [-1, -1, -1, 0, 0, 1, 1, 1]; dc8: list[int] = [-1, 0, 1, -1, 1, -1, 0, 1]

N = int(input())
cnt = 0
N_max = N
while N > 1:
    if N & 1:
        N = 3 * N + 1
    else:
        N //= 2
    cnt += 1
    N_max = max(N_max, N)
print(cnt)
print(N_max)
0