結果

問題 No.2534 コラッツ数列
ユーザー daiota
提出日時 2023-11-11 00:54:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 165,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-26 02:30:30
合計ジャッジ時間 2,272 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)



int main(void){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j,k;

	int N;
	cin >> N;

	int n=N;
	int ans=1;
	while(1){
		if(n==1){
			ans++;
			break;
		}
		else if(n%2==0){
			n/=2;
			ans+=2;
		}
		else{
			n=3*n+1;
			ans+=2;
		}

		if(ans>50) break;

	}


	if(ans<=50){
		cout << "Yes" << endl;
		cout << ans << endl;
	}else{
		cout << "No" << endl;
	}


	return 0;
}
0