結果
| 問題 |
No.2939 Sigma Popcount Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-18 21:48:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| コード長 | 382 bytes |
| コンパイル時間 | 2,008 ms |
| コンパイル使用メモリ | 193,140 KB |
| 最終ジャッジ日時 | 2025-02-24 20:38:34 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
void solve(){
using ll=long long;
ll N;cin>>N;
ll ans=0;
for(int i=0;i<60;++i){
ll x=N-((ll)1<<i)+1;
if(x<=0)continue;
ans+=((ll)1<<i)*(x/((ll)1<<(i+1)));
ll r=x%((ll)1<<(i+1));
ans+=min(r,(ll)1<<i);
}
cout<<ans<<'\n';
}
int main(){
cin.tie(0)->sync_with_stdio(0);
int T;cin>>T;
while(T--)solve();
}