結果
| 問題 | No.737 PopCount | 
| コンテスト | |
| ユーザー |  merom686 | 
| 提出日時 | 2018-09-28 22:31:44 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 1,000 ms | 
| コード長 | 749 bytes | 
| コンパイル時間 | 628 ms | 
| コンパイル使用メモリ | 74,344 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 06:54:01 | 
| 合計ジャッジ時間 | 1,338 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 15 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
constexpr int P = 1000000007;
int main() {
    ll n;
    cin >> n;
    n++;
    ll r = 0, c = 0, a = 0;
    for (int k = 60; k >= 0; k--) {
        ll m = 1LL << k;
        if (n & m) {
            ll t = m / 2;
            ll s = (m + P - 1) % P;
            r += (t % P + t / 2 % P * (k - 1) % P) % P * s % P;
            r += a * (m % P) % P * c % P;
            r += a * (t % P) % P * k % P;
            r += c * s % P * (t % P) % P;
            c++;
            a += m;
            a %= P;
            r %= P;
        }
    }
    cout << r << endl;
    return 0;
}
            
            
            
        