結果
問題 | No.2534 コラッツ数列 |
ユーザー |
|
提出日時 | 2023-11-10 21:52:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 356 bytes |
コンパイル時間 | 1,804 ms |
コンパイル使用メモリ | 192,408 KB |
最終ジャッジ日時 | 2025-02-17 20:38:41 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ll n; cin>>n; ll ans=1; while(ans<=100){ ans++; if(n==1){ break; } if(n%2==0){ ans++; n/=2; }else{ ans++; n=3*n+1; } } if(ans<=50){ cout<<"Yes"<<endl; cout<<ans<<endl; }else{ cout<<"No"<<endl; } }