結果
問題 | No.887 Collatz |
ユーザー |
![]() |
提出日時 | 2020-02-05 06:42:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 252 bytes |
コンパイル時間 | 574 ms |
コンパイル使用メモリ | 63,016 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 21:33:50 |
合計ジャッジ時間 | 1,375 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <iostream> using namespace std; int main(void) { int n; cin >> n; int cnt = 0, nmax = n; while (n != 1) { ++cnt; nmax = max(nmax, n); if (n % 2 == 0) n /= 2; else n = n * 3 + 1; } cout << cnt << "\n" << nmax << "\n"; return 0; }