結果
| 問題 | 
                            No.887 Collatz
                             | 
                    
| コンテスト | |
| ユーザー | 
                             eyeSharp
                         | 
                    
| 提出日時 | 2019-10-07 20:37:35 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 556 bytes | 
| コンパイル時間 | 1,473 ms | 
| コンパイル使用メモリ | 159,472 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-10-14 14:45:52 | 
| 合計ジャッジ時間 | 2,453 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 WA * 1 | 
ソースコード
/*
    No.887 Collatz
    https://yukicoder.me/problems/no/887
*/
#include <bits/stdc++.h>
using namespace std;
void collatz(long long int n) {
    long long int max = -1;
    long long int i = 0;
    while (n != 1) {
        if (max < n)
            max = n;
        i++;
        if (n % 2 == 0) {
            n /= 2;
        } else {
            n = 3 * n + 1;
        }
    }
    cout << i << endl;
    cout << max << endl;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    unsigned long long int n = 0;
    cin >> n;
    collatz(n);
}
            
            
            
        
            
eyeSharp