結果

問題 No.887 Collatz
ユーザー Heart_BlueHeart_Blue
提出日時 2023-09-10 18:50:50
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 1,287 ms
コンパイル使用メモリ 127,728 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 10:00:50
合計ジャッジ時間 2,061 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <valarray>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int maxv = max(4, n);
	int ans = 0;
	while (n != 1)
	{
		if (n & 1) n = 3 * n + 1;
		else n = n / 2;
		maxv = max(maxv,n);
		ans++;
	}
	cout << ans << endl;
	cout << maxv << endl;
	return 0;
}
0