結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2019-09-20 21:24:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 490 bytes |
コンパイル時間 | 607 ms |
コンパイル使用メモリ | 73,112 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 16:11:22 |
合計ジャッジ時間 | 1,582 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; using ll = long long; int main() { int n; cin >> n; int i1 = -1, n_max = n; for (int i = 0;; i++) { if (i1 < 0 && n == 1) { i1 = i; break; } n = n % 2 == 0 ? n / 2 : n * 3 + 1; n_max = max(n_max, n); } cout << i1 << '\n' << n_max << endl; return 0; }