結果

問題 No.887 Collatz
ユーザー mkawa2
提出日時 2019-12-15 01:37:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-28 10:18:36
合計ジャッジ時間 1,939 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n = int(input())
    mx = n
    i = 0
    while n != 1:
        if n > mx: mx = n
        if n % 2:
            n = 3 * n + 1
        else:
            n //= 2
        i += 1
    print(i)
    print(mx)
main()
0