結果

問題 No.887 Collatz
ユーザー futamegawa
提出日時 2023-08-12 19:27:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 418 bytes
コンパイル時間 1,557 ms
コンパイル使用メモリ 165,260 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-20 09:59:57
合計ジャッジ時間 2,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using ll = long long;
using llu = long long unsigned;

using namespace std;

int main() {
    ll n;
    cin >> n;
    ll maxV, count;
    maxV = n;
    count = 0;
    for (count = 0; count <= 400; count++) {
        if (n==1) { break; }
        if (n%2) { n=3*n+1; }
        else { n/=2; }
        maxV = max(maxV, n);
    }
    cout << count << endl;
    cout << maxV << endl;
    return 0;
}
0