結果

問題 No.2067 ±2^k operations
ユーザー karinohito
提出日時 2022-09-01 23:59:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 1,968 ms
コンパイル使用メモリ 200,420 KB
最終ジャッジ日時 2025-02-07 00:28:25
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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