結果

問題 No.887 Collatz
ユーザー gorugo30
提出日時 2021-02-23 12:57:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 259 bytes
コンパイル時間 536 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 53,816 KB
最終ジャッジ日時 2024-09-22 08:28:44
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
if N == 1:
    print(0)
    print(1)
    exit()
i1 = -1
nmax = N
i = 0
while i1 == -1:
    if N % 2:
        N = 3 * N + 1
    else:
        N = N // 2
    if N == 1:
        i1 = i
    nmax = max(nmax, N)
    i += 1
print(i1 + 1)
print(nmax)
0