結果

問題 No.2534 コラッツ数列
ユーザー nonon
提出日時 2023-11-10 21:27:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 192,604 KB
最終ジャッジ日時 2025-02-17 20:23:41
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin>>N;
    int ans=0;
    while(ans<=50){
        ans++;
        if(N==1){
            ans++;
            cout<<"Yes\n";
            cout<<ans<<endl;
            return 0;
        }
        if(N%2==0){
            ans++;
            N/=2;
        }
        else{
            ans++;
            N=3*N+1;
        }
    }
    cout<<"No\n";
}
0