結果

問題 No.887 Collatz
ユーザー d_sei
提出日時 2019-10-13 19:03:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 86,748 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 07:26:50
合計ジャッジ時間 1,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include <vector>
#include<cmath>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long int lint;
int main() {
	lint n0;
	cin >> n0;
	if (n0 == 1) {
		cout << 3 << endl << 4 << endl;
	}
	else {
		vector<lint>vec(1000);
		int cnt = 0;
		while (n0 > 1) {
			vec.at(cnt) = n0;
			if (n0 % 2) {
				n0 = 3 * n0 + 1;
			}
			else {
				n0 = n0 / 2;
			}
			cnt++;
		}
		sort(vec.begin(), vec.end());
		cout << cnt << endl << vec.at(999) << endl;
	}



	

}



	
0