結果

問題 No.887 Collatz
ユーザー cureskol
提出日時 2020-03-18 14:45:35
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 227 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 165,720 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 01:54:49
合計ジャッジ時間 2,338 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int n;cin>>n;
    int mx=n,cnt=0;
    while(n!=1){
        if(n&1)n=n*3+1;
        else n>>=1;
        mx=max(mx,n);cnt++;
    }
    cout<<cnt<<endl<<mx<<endl;
}
0