結果

問題 No.2067 ±2^k operations
ユーザー karinohitokarinohito
提出日時 2022-08-31 00:29:35
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 3,634 ms
コンパイル使用メモリ 278,880 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 07:21:55
合計ジャッジ時間 6,384 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 49 ms
5,376 KB
testcase_02 AC 50 ms
5,376 KB
testcase_03 AC 52 ms
5,376 KB
testcase_04 AC 51 ms
5,376 KB
testcase_05 AC 51 ms
5,376 KB
testcase_06 AC 35 ms
5,376 KB
testcase_07 AC 126 ms
5,376 KB
testcase_08 AC 128 ms
5,376 KB
testcase_09 AC 130 ms
5,376 KB
testcase_10 AC 128 ms
5,376 KB
testcase_11 AC 128 ms
5,376 KB
testcase_12 AC 132 ms
5,376 KB
testcase_13 AC 129 ms
5,376 KB
testcase_14 AC 128 ms
5,376 KB
testcase_15 AC 129 ms
5,376 KB
testcase_16 AC 130 ms
5,376 KB
testcase_17 AC 121 ms
5,376 KB
testcase_18 AC 127 ms
5,376 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 18 ms
5,376 KB
testcase_21 AC 187 ms
5,376 KB
testcase_22 AC 184 ms
5,376 KB
testcase_23 AC 188 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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