結果

問題 No.887 Collatz
ユーザー tactac
提出日時 2019-09-20 21:25:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 1,356 ms
コンパイル使用メモリ 163,416 KB
実行使用メモリ 11,344 KB
最終ジャッジ日時 2023-10-12 17:41:14
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
11,216 KB
testcase_01 AC 6 ms
11,136 KB
testcase_02 AC 6 ms
11,340 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 6 ms
11,088 KB
testcase_06 AC 7 ms
11,204 KB
testcase_07 AC 6 ms
11,276 KB
testcase_08 AC 6 ms
11,124 KB
testcase_09 AC 6 ms
11,084 KB
testcase_10 AC 6 ms
11,212 KB
testcase_11 AC 7 ms
11,260 KB
testcase_12 AC 7 ms
11,200 KB
testcase_13 AC 7 ms
11,152 KB
testcase_14 AC 6 ms
11,192 KB
testcase_15 AC 6 ms
11,112 KB
testcase_16 AC 6 ms
11,152 KB
testcase_17 AC 6 ms
11,100 KB
testcase_18 AC 6 ms
11,280 KB
testcase_19 AC 7 ms
11,144 KB
testcase_20 AC 7 ms
11,132 KB
testcase_21 AC 6 ms
11,344 KB
testcase_22 AC 6 ms
11,084 KB
testcase_23 AC 7 ms
11,260 KB
testcase_24 AC 6 ms
11,124 KB
testcase_25 AC 6 ms
11,216 KB
testcase_26 AC 6 ms
11,084 KB
testcase_27 AC 7 ms
11,240 KB
testcase_28 AC 6 ms
11,200 KB
testcase_29 AC 6 ms
11,132 KB
testcase_30 AC 6 ms
11,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {
    int n;
    cin >> n;
    const int maxn = 1000000;
    ll table[maxn] = {0};
    table[0] = n;
    rep(i, maxn - 1) {
        if (table[i] % 2 == 0) {
            table[i + 1] = table[i] / 2;
        } else {
            table[i + 1] = 3 * table[i] + 1;
        }
    }
    int ans = -1;
    rep(i, maxn) if (table[i] == 1) { ans = i; break; }
    ll maxx = -1;
    rep(i, maxn) chmax(maxx, table[i]);
    cout << ans << endl << maxx << endl;
}
0