結果

問題 No.737 PopCount
ユーザー りあんりあん
提出日時 2018-09-28 23:04:39
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 2,470 ms
コンパイル使用メモリ 194,028 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 11:56:19
合計ジャッジ時間 2,426 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

const int M = 1000000007;
const int iM = 500000004;

int main() {
    long long n;
    cin >> n;
    long long sum = 0;
    for (int i = 0; n >> i; ++i) {
        long long c = (n + 1) / (1L << (i + 1)) * (1L << i);
        long long m = (c * 2 - 1) % M * (c * 2 % M) % M * iM % M;
        sum = (sum + (m + c % M * (1L << i) % M) % M * iM % M) % M;
        if ((n + 1) % (1L << (i + 1)) >= (1L << i)) {
            sum = (sum + (c * 2 + (1L << i) % M + n) % M * ((n - c * 2 - (1L << i) + 1) % M) % M * iM) % M;
        }
    }
    cout << sum << "\n";
    return 0;
}
0