結果

問題 No.3631 Collatz conjecture
コンテスト
ユーザー Timosh
提出日時 2026-08-21 21:22:05
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.90.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,759 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,197 ms
コンパイル使用メモリ 360,532 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2026-08-21 21:22:25
合計ジャッジ時間 4,785 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 52 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vi vector<int>
#define vii vector<vi>
#define ld long double
#define pii pair<int, int>
mt19937 mt(time(0));

namespace io
{
    template <typename T, typename F>
    istream &operator>>(istream &cin, pair<T, F> &pr)
    {
        cin >> pr.first >> pr.second;
        return cin;
    }
    template <typename T, typename F>
    ostream &operator<<(ostream &cout, pair<T, F> &pr)
    {
        cout << pr.first << ' ' << pr.second;
        return cout;
    }
    template <typename T>
    istream &operator>>(istream &cin, vector<T> &vec)
    {
        for (T &i : vec)
            cin >> i;
        return cin;
    }
    template <typename T>
    ostream &operator<<(ostream &cout, vector<T> vec)
    {
        for (T i : vec)
            cout << i << ' ';
        return cout;
    }
}
using namespace io;

int M = 998244353;

int pw(int x, int y)
{
    x %= M;
    int res = 1;
    while (y)
    {
        if (y & 1)
            res = res * x % M;
        x = x * x % M, y /= 2;
    }
    return res;
}

int inv(int x) { return pw(x, M - 2); }

void solve()
{
    int n, x = 0;
    cin >> n;
    while (n != 1)
        n = (n % 2 ? 3 * n + 1 : n / 2), x++;
    cout << x;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
        solve(), cout << '\n';
    return 0;
}
0