結果

問題 No.2939 Sigma Popcount Problem
ユーザー cled0328
提出日時 2024-10-18 21:38:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 397 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 192,224 KB
最終ジャッジ日時 2025-02-24 20:34:08
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;cin>>t;
    for(int i=0;i<t;i++){
        long long n;cin>>n;
        long long ans=0;
        for(int j=0;j<40;j++){
            ans+=n>>(j+1)<<j;
            if(n>>j&1){
                ans+=n&((1ull<<j)-1);
                ans++;
            }
            //cout<<j<<" "<<ans<<"\n";
        }
        cout<<ans<<"\n";
    }
}
0