結果
| 問題 |
No.2939 Sigma Popcount Problem
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2024-10-18 21:35:37 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 235 ms / 2,000 ms |
| コード長 | 549 bytes |
| コンパイル時間 | 5,485 ms |
| コンパイル使用メモリ | 307,460 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-18 22:25:54 |
| 合計ジャッジ時間 | 8,892 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;
typedef long long ll;
int main() {
int t;
cin >> t;
while (t--) {
ll n;
cin >> n;
n++;
ll ans = 0;
ll nw = 2;
while (nw <= 3e12) {
ll am = n % nw;
ll cnt = n / nw;
ans += cnt * (nw / 2);
ans += max(0LL, am - nw / 2);
nw *= 2;
}
cout << ans << endl;
}
}
SnowBeenDiding