結果

問題 No.2067 ±2^k operations
ユーザー karinohitokarinohito
提出日時 2022-09-01 23:59:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 313 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 203,884 KB
実行使用メモリ 30,184 KB
最終ジャッジ日時 2024-04-26 23:58:16
合計ジャッジ時間 6,721 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 39 ms
6,816 KB
testcase_02 AC 39 ms
6,944 KB
testcase_03 AC 41 ms
6,940 KB
testcase_04 AC 41 ms
6,940 KB
testcase_05 AC 42 ms
6,940 KB
testcase_06 AC 20 ms
6,940 KB
testcase_07 AC 313 ms
30,056 KB
testcase_08 AC 309 ms
30,184 KB
testcase_09 AC 313 ms
29,924 KB
testcase_10 AC 309 ms
29,924 KB
testcase_11 AC 307 ms
29,928 KB
testcase_12 AC 294 ms
29,932 KB
testcase_13 AC 289 ms
29,928 KB
testcase_14 AC 303 ms
29,924 KB
testcase_15 AC 301 ms
30,056 KB
testcase_16 AC 307 ms
30,056 KB
testcase_17 AC 28 ms
6,944 KB
testcase_18 AC 24 ms
6,944 KB
testcase_19 AC 17 ms
6,944 KB
testcase_20 AC 18 ms
6,944 KB
testcase_21 AC 23 ms
6,940 KB
testcase_22 AC 23 ms
6,940 KB
testcase_23 AC 23 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
unordered_map<ll,ll>M;
ll S(ll N){
    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;
    assert(1<=T&&T<=1e4);
    M[0]=0;
    while(T--) {
        ll N;
        cin>>N;
        assert(1<=N&&N<=1e17);
        cout<<S(N)<<endl;
    }
}
0