結果

問題 No.887 Collatz
ユーザー alcoholamp
提出日時 2019-10-02 11:55:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-03 05:57:58
合計ジャッジ時間 1,910 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

class Problem0887:

    def collatz(this, num):
        res = [num]
        while num != 1:
            if num % 2 == 0:
                num /= 2
            else:
                num = num * 3 + 1
            res.append(int(num))
        return res
    def solve(this):
        n = int(input())
        t = this.collatz(n)
        print(len(t) - 1)
        print(max(t))
    

if __name__ == "__main__":
    problem = Problem0887()
    problem.solve()
0