結果

問題 No.887 Collatz
ユーザー alexara1123
提出日時 2019-09-20 22:05:39
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 580 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 88,832 KB
最終ジャッジ日時 2024-09-14 17:40:34
合計ジャッジ時間 6,218 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import gcd
from datetime import date
from math import factorial
import functools
from heapq import*
from collections import deque
import collections
import math
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float("inf")


def main():
    n = int(input())
    ansi = 0
    nmax = n
    while n != 1:
        if n % 2 == 0:
            n //= 2
        else:
            n = 3 * n + 1
        ansi += 1
        nmax = max(nmax, n)
    print(ansi)
    print(nmax)


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