結果

問題 No.2939 Sigma Popcount Problem
ユーザー a1048576
提出日時 2024-10-18 21:24:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 4,033 ms
コンパイル使用メモリ 229,876 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-10-18 21:46:42
合計ジャッジ時間 7,273 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all> 
using mint = atcoder::modint998244353;
#define int long long
signed main() {
  int T;
  cin >> T;
  vector<int> p(61,1);
  for(int i = 0; i < 60; i++) p[i+1] = p[i]*2;
  while(T--) {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 0; i < 50; i++) {
      int c = n/p[i+1];
      ans+=c*p[i];
      if(n%p[i+1] >= p[i]) ans+=n%p[i+1]-p[i]+1;
    }
    cout << ans << endl;
  }
}
0