結果

問題 No.2067 ±2^k operations
ユーザー karinohitokarinohito
提出日時 2022-08-30 16:46:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 205 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 200,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 01:36:14
合計ジャッジ時間 6,562 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 56 ms
5,376 KB
testcase_02 AC 56 ms
5,376 KB
testcase_03 AC 55 ms
5,376 KB
testcase_04 AC 54 ms
5,376 KB
testcase_05 AC 58 ms
5,376 KB
testcase_06 AC 42 ms
5,376 KB
testcase_07 AC 144 ms
5,376 KB
testcase_08 AC 144 ms
5,376 KB
testcase_09 AC 146 ms
5,376 KB
testcase_10 AC 142 ms
5,376 KB
testcase_11 AC 142 ms
5,376 KB
testcase_12 AC 141 ms
5,376 KB
testcase_13 AC 144 ms
5,376 KB
testcase_14 AC 147 ms
5,376 KB
testcase_15 AC 145 ms
5,376 KB
testcase_16 AC 141 ms
5,376 KB
testcase_17 AC 133 ms
5,376 KB
testcase_18 AC 143 ms
5,376 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 18 ms
5,376 KB
testcase_21 AC 199 ms
5,376 KB
testcase_22 AC 200 ms
5,376 KB
testcase_23 AC 205 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
unordered_map<ll, ll> M;
ll dfs(ll N) {
    if (N <= 0)return 0;
    if (M.count(N))return M[N];
    M[N] = dfs(N / 2) + dfs((N + 3) / 4 - 1) + dfs((N + 1) / 4) + (N + 3) / 4 + (N + 1) / 4;
    return M[N];
}
int main() {
    ll T;
    cin >> T;
    while (T--) {
        ll N;
        cin >> N;
        M.clear();
        cout << dfs(N) << endl;
    }
}
0