結果
| 問題 |
No.887 Collatz
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-20 21:23:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 422 bytes |
| コンパイル時間 | 1,467 ms |
| コンパイル使用メモリ | 165,272 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 16:10:04 |
| 合計ジャッジ時間 | 2,362 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n0;
cin >> n0;
ll nmax = n0;
int i1 = 0;
while (n0 != 1) {
if (n0 % 2 == 0) n0 /= 2;
else {
n0 = n0 * 3 + 1;
nmax = max(nmax, n0);
}
i1++;
}
cout << i1 << endl;
cout << nmax << endl;
return 0;
}