結果
| 問題 | 
                            No.2534 コラッツ数列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             KDKJ
                         | 
                    
| 提出日時 | 2023-11-27 23:21:11 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 48 ms / 2,000 ms | 
| コード長 | 335 bytes | 
| コンパイル時間 | 1,667 ms | 
| コンパイル使用メモリ | 81,664 KB | 
| 実行使用メモリ | 53,888 KB | 
| 最終ジャッジ日時 | 2024-09-26 12:38:58 | 
| 合計ジャッジ時間 | 3,217 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 33 | 
ソースコード
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)
            
            
            
        
            
KDKJ