結果

問題 No.641 Team Contest Estimation
ユーザー e869120e869120
提出日時 2018-01-26 23:06:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 294 ms / 2,000 ms
コード長 884 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 64,972 KB
実行使用メモリ 4,472 KB
最終ジャッジ日時 2023-08-27 19:41:58
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 294 ms
4,380 KB
testcase_06 AC 293 ms
4,380 KB
testcase_07 AC 294 ms
4,388 KB
testcase_08 AC 294 ms
4,472 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 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;
		}
		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