結果
| 問題 | No.3631 Collatz conjecture |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-22 11:08:20 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 770µs | |
| コード長 | 1,453 bytes |
| 記録 | |
| コンパイル時間 | 3,414 ms |
| コンパイル使用メモリ | 350,860 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-08-22 11:08:27 |
| 合計ジャッジ時間 | 5,120 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 53 |
ソースコード
#define YUKICODER
// #define CODEFORCES
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pob pop_back
#define eb emplace_back
#define nall(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define accu accumulate
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#ifdef CODEFORCES
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define yesno(a) cout<<(a?"YES\n":"NO\n")
#else
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
#define yesno(a) cout<<(a?"Yes\n":"No\n")
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template<class T> using vec = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vv<T>>;
const ll MOD = 998244353ll;
// const ll MOD = 1000000007ll;
void solve();
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
unsigned T = 1;
// cin >> T;
cout << fixed << setprecision(20);
while (T--) solve();
return 0;
}
void solve(){
int N;
cin >> N;
if (N == 1){
cout << 3 << endl;
return;
}
int ans = 0;
while (N != 1){
if (N%2 == 0) N = N/2;
else N = 3*N+1;
ans++;
}
cout << ans << endl;
}