結果

問題 No.887 Collatz
ユーザー はむ吉🐹
提出日時 2019-09-20 21:27:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 384 bytes
コンパイル時間 185 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-14 16:18:19
合計ジャッジ時間 2,053 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools


def solve(n0):
    nmax = n0
    n = n0
    for i in itertools.count(1):
        if n % 2 == 0:
            n //= 2
        else:
            n = 3 * n + 1
        nmax = max(n, nmax)
        if n == 1:
            return i, nmax


def main():
    n0 = int(input())
    imax, nmax = solve(n0)
    print(imax)
    print(nmax)


if __name__ == "__main__":
    main()
0