結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2020-08-23 17:18:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 387 bytes |
コンパイル時間 | 2,168 ms |
コンパイル使用メモリ | 191,172 KB |
最終ジャッジ日時 | 2025-01-13 12:39:48 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; int main() { lint N; cin >> N; lint i1 = 0; long nmax = N; while (N != 1) { if (N % 2 == 0) { N /= 2; } else { N = 3 * N + 1; } i1 ++; nmax = fmax(nmax, N); } cout << i1 << endl; cout << nmax << endl; return 0; }