結果

問題 No.887 Collatz
ユーザー ate
提出日時 2019-11-25 13:23:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 270 bytes
コンパイル時間 1,803 ms
コンパイル使用メモリ 192,636 KB
最終ジャッジ日時 2025-01-08 05:34:58
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ansi=0;
    int ansm=n;
    while(n!=1){
        if(n&1)n=3*n+1;
        else n/=2;
        ansi++;
        ansm=max(ansm,n);
    }
    cout<<ansi<<endl;
    cout<<ansm<<endl;
    
}
0