結果

問題 No.887 Collatz
ユーザー ゆきのんゆきのん
提出日時 2019-09-20 22:06:04
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 631 bytes
コンパイル時間 1,424 ms
コンパイル使用メモリ 157,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 17:42:04
合計ジャッジ時間 2,251 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;


int main(){
    LL n;cin >> n;
    LL mx = 0, ma = -1;
    for (int i = 0; i <= 400; i++) {
        if(ma==-1&&n==1){
            ma = i;
        }
        mx = max(mx, n);
        if(n%2==0) n /= 2;
        else n = n * 3 + 1;
    }
    cout << ma << endl;
    cout << mx << endl;
    return 0;
}
0