結果

問題 No.887 Collatz
ユーザー tactac
提出日時 2019-09-20 21:23:30
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,234 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 165,716 KB
実行使用メモリ 4,796 KB
最終ジャッジ日時 2023-10-12 17:38:35
合計ジャッジ時間 2,599 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,644 KB
testcase_01 AC 3 ms
4,512 KB
testcase_02 AC 3 ms
4,784 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,488 KB
testcase_06 AC 3 ms
4,496 KB
testcase_07 AC 3 ms
4,668 KB
testcase_08 AC 2 ms
4,504 KB
testcase_09 AC 3 ms
4,792 KB
testcase_10 AC 3 ms
4,504 KB
testcase_11 AC 3 ms
4,488 KB
testcase_12 AC 3 ms
4,508 KB
testcase_13 AC 3 ms
4,668 KB
testcase_14 AC 3 ms
4,488 KB
testcase_15 AC 3 ms
4,528 KB
testcase_16 AC 3 ms
4,600 KB
testcase_17 AC 3 ms
4,484 KB
testcase_18 AC 3 ms
4,600 KB
testcase_19 AC 3 ms
4,512 KB
testcase_20 AC 3 ms
4,640 KB
testcase_21 AC 3 ms
4,640 KB
testcase_22 AC 3 ms
4,796 KB
testcase_23 AC 3 ms
4,480 KB
testcase_24 AC 3 ms
4,516 KB
testcase_25 AC 3 ms
4,616 KB
testcase_26 AC 3 ms
4,500 KB
testcase_27 AC 2 ms
4,484 KB
testcase_28 AC 3 ms
4,508 KB
testcase_29 AC 3 ms
4,532 KB
testcase_30 AC 3 ms
4,588 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 = 300000;
    int 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; }
    int maxx = -1;
    rep(i, maxn) chmax(maxx, table[i]);
    cout << ans << endl << maxx << endl;
}
0