結果
| 問題 | 
                            No.887 Collatz
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-09-25 04:34:13 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 340 bytes | 
| コンパイル時間 | 2,072 ms | 
| コンパイル使用メモリ | 191,116 KB | 
| 最終ジャッジ日時 | 2025-01-07 19:07:11 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 28 | 
ソースコード
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int a = 0, b = n;
  while (n > 1) {
    if (n % 2) {
      n = n * 3 + 1;
    } else {
      n /= 2;
    }
    b = max(b, n);
    a++;
  }
  cout << a << '\n' << b << '\n';
  return 0;
}