結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-12-18 00:30:52 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 23 ms / 2,000 ms |
| コード長 | 389 bytes |
| コンパイル時間 | 2,008 ms |
| コンパイル使用メモリ | 192,888 KB |
| 最終ジャッジ日時 | 2025-01-27 02:46:16 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define LP pair<ll, ll>
int main() {
int n;
cin >> n;
int mx = n;
int cnt = 0;
while (n != 1) {
if (n%2==0) n /= 2;
else n = 3*n+1;
mx = max(mx,n);
cnt++;
}
cout << cnt << endl;
cout << mx << endl;
return 0;
}