結果

問題 No.2534 コラッツ数列
ユーザー miya145592
提出日時 2023-11-10 21:47:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-09-26 01:22:02
合計ジャッジ時間 2,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

def P(n):
    cnt = 0
    # 1
    nn = n
    cnt+=1
    while cnt<=50:
        # 2
        if nn==1:
            cnt+=1
            break
        cnt+=1
        # 3
        if nn%2==0:
            nn//=2
            cnt+=1
        else:
            nn=3*nn+1
            cnt+=1
    return cnt


import sys
input = sys.stdin.readline
N = int(input())
cnt = P(N)
if cnt<=50:
    print("Yes")
    print(cnt)
else:
    print("No")
0