結果

問題 No.737 PopCount
ユーザー chocoruskchocorusk
提出日時 2018-09-28 22:48:23
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 786 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 85,960 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-20 11:48:35
合計ジャッジ時間 1,724 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
   
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	ll n;
	cin>>n;
	ll ans=0;
	ll m=0;
	for(ll i=59; i>=0; i--){
		if((n&(1ll<<i))==0) continue;
		if(i>=1){
			ans+=(((1ll<<(i-1))%MOD)*(((1ll<<i)-1)%MOD)%MOD*(i+1)%MOD*500000004%MOD);
        }
		ans+=(m%MOD*((1ll<<(i-1))%MOD)*i%MOD);
		ans+=((n+(1ll<<i))%MOD*((n-(1ll<<i)+1)%MOD)%MOD*500000004%MOD);
		ans+=(m%MOD*((n-(1ll<<i)+1)%MOD)%MOD);
		ans%=MOD;
		n-=(1ll<<i);
		m+=(1ll<<i);
	}
	cout<<ans<<endl;
    return 0;
}
0