結果
問題 |
No.2939 Sigma Popcount Problem
|
ユーザー |
|
提出日時 | 2024-10-20 13:52:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 1,935 ms |
コンパイル使用メモリ | 193,132 KB |
最終ジャッジ日時 | 2025-02-24 21:48:56 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; constexpr int MOD=998244353; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(l);i<(int)(r);i++) #define all(v) v.begin(),v.end() void solve(); int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int test_case; cin>>test_case; while (test_case--){ solve(); } } void solve(){ ll N; cin>>N; N++; ll ans=0; rep(i,40){ ans+=(N/(2ll<<i))*(1ll<<i); ans+=max(N%(2ll<<i)-(1ll<<i),0ll); } cout<<ans<<'\n'; }