結果

問題 No.2534 コラッツ数列
コンテスト
ユーザー KDKJ
提出日時 2023-11-27 23:21:11
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 72 ms / 2,000 ms
+ 206µs
コード長 335 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,820 ms
コンパイル使用メモリ 95,560 KB
実行使用メモリ 79,320 KB
最終ジャッジ日時 2026-09-04 20:08:53
合計ジャッジ時間 5,748 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code


from collections import defaultdict


def dfs(x):
    global c
    c += 1
    if c >= 50:
        print("No")
        exit()

    if x == 1:
        c += 1
        return
    else:
        c += 1
        if x % 2 == 0:
            dfs(x//2)
        else:
            dfs(x*3+1)


n = int(input())
c = 0

dfs(n)
print("Yes")
print(c)
0