結果

問題 No.2534 コラッツ数列
ユーザー Ywestbuilderk
提出日時 2024-01-22 20:19:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 65,920 KB
最終ジャッジ日時 2025-02-18 22:10:16
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 1;
	while(true){
		ans++;
		if(n == 1){break;}
		else{
			if(n % 2 == 0){ans++;n /= 2;}
			else{ans++;n = 3 * n + 1;}
		}
		if(ans > 50){cout << "No";return 0;}
	}
	cout << "Yes" << endl << ans << endl;
}

0