結果

問題 No.641 Team Contest Estimation
ユーザー e869120e869120
提出日時 2018-01-26 23:05:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 859 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 64,220 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 19:40:38
合計ジャッジ時間 2,180 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;

long long N, K, A[100009], sigma, sum, mod = 1000000009;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 0; i < K; i++) {
		long long P1 = 0, P2 = 0;
		for (int j = 1; j <= N; j++) {
			if ((A[j] / (1LL << i)) % 2 == 0) P1 += (1LL << i);
			else P2 += (1LL << i);
		}
		P1 %= mod; P2 %= mod;
		long long S1 = sigma + ((1LL << i) % mod)*((P1*P1) % mod) + (2LL * P1*sum); S1 %= mod;
		long long S2 = sigma + ((1LL << i) % mod)*((P2*P2) % mod) + (2LL * P2*sum); S2 %= mod;
		long long T = sum * 2LL; T += ((1LL << i) % mod)*((P1 + P2) % mod); T %= mod;
		sigma = S1 + S2; sigma %= mod; sum = T;
	}
	cout << sum << endl;
	long long ans = sigma;
	for (int i = 0; i < K; i++) { ans *= 2; ans %= mod; }
	ans = ans - (sum*sum) % mod + mod; ans %= mod;
	cout << ans << endl;
	return 0;
}
0