結果
問題 |
No.887 Collatz
|
ユーザー |
|
提出日時 | 2019-09-28 04:15:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 290 bytes |
コンパイル時間 | 2,073 ms |
コンパイル使用メモリ | 192,116 KB |
最終ジャッジ日時 | 2025-01-07 19:43:59 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n0; cin >> n0; int i1 = 0; int nmax = n0; while (n0 != 1) { if (n0 & 1) n0 = 3 * n0 + 1; else n0 /= 2; nmax = max(nmax, n0); ++i1; } cout << i1 << endl; cout << nmax << endl; return 0; }