結果

問題 No.2067 ±2^k operations
ユーザー karinohitokarinohito
提出日時 2022-08-31 00:31:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 325 bytes
コンパイル時間 2,605 ms
コンパイル使用メモリ 201,480 KB
実行使用メモリ 30,184 KB
最終ジャッジ日時 2024-04-25 07:23:54
合計ジャッジ時間 6,523 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 35 ms
6,156 KB
testcase_02 AC 33 ms
6,284 KB
testcase_03 AC 34 ms
6,156 KB
testcase_04 AC 35 ms
6,156 KB
testcase_05 AC 34 ms
6,412 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 234 ms
29,932 KB
testcase_08 AC 238 ms
29,928 KB
testcase_09 AC 243 ms
30,056 KB
testcase_10 AC 232 ms
29,928 KB
testcase_11 AC 238 ms
29,928 KB
testcase_12 AC 254 ms
29,928 KB
testcase_13 AC 242 ms
30,184 KB
testcase_14 AC 244 ms
29,924 KB
testcase_15 AC 229 ms
30,184 KB
testcase_16 AC 245 ms
30,060 KB
testcase_17 AC 24 ms
5,376 KB
testcase_18 AC 21 ms
5,376 KB
testcase_19 AC 15 ms
5,376 KB
testcase_20 AC 15 ms
5,376 KB
testcase_21 AC 21 ms
5,376 KB
testcase_22 AC 22 ms
5,376 KB
testcase_23 AC 20 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(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;
    M[0]=0;
    while(T--) {
        ll N;
        cin>>N;
        cout<<S(N)<<endl;
    }
}
0