結果

問題 No.1958 Bit Game
ユーザー 👑 ygussanyygussany
提出日時 2022-05-27 21:42:54
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 1,081 bytes
コンパイル時間 1,034 ms
コンパイル使用メモリ 32,612 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 20:02:40
合計ジャッジ時間 15,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 472 ms
4,348 KB
testcase_11 AC 769 ms
4,348 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 1,012 ms
4,348 KB
testcase_15 WA -
testcase_16 AC 90 ms
4,348 KB
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,505 ms
4,348 KB
testcase_21 WA -
testcase_22 AC 858 ms
4,348 KB
testcase_23 AC 229 ms
4,348 KB
testcase_24 RE -
testcase_25 AC 427 ms
4,348 KB
testcase_26 AC 1,270 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 1,444 ms
4,348 KB
testcase_29 AC 740 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353, bit[19] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144};

long long pow_mod(int n, long long k)
{
	long long N, ans = 1;
	for (N = n; k > 0; k >>= 1, N = N * N % Mod) if (k & 1) ans = ans * N % Mod;
	return ans;
}

int main()
{
	int i, N, X, Y, A[200001], B[200001];
	scanf("%d %d %d", &N, &X, &Y);
	for (i = 1; i <= X; i++) scanf("%d", &(A[i]));
	for (i = 1; i <= Y; i++) scanf("%d", &(B[i]));
	
	int k, x, y;
	long long ans = 0, tmp;
	for (k = 0; k < 18; k++) {
		for (i = 1, x = 0; i <= X; i++) if ((A[i] & bit[k]) != 0) x++;
		for (i = 1, y = 0; i <= Y; i++) if ((B[i] & bit[k]) != 0) y++;
		if (x == 0 || y == 0) continue;
		for (i = 1, tmp = 0; i < N; i++) tmp += pow_mod(y, i) * pow_mod(Y, N - i - 1) % Mod * (pow_mod(X, N) - pow_mod(X, N - i) * pow_mod(X - x, i) % Mod + Mod) % Mod;
		tmp = (tmp % Mod * (Y - y) + pow_mod(y, N) * (pow_mod(X, N) - pow_mod(X - x, N) + Mod)) % Mod;
		ans += bit[k] * tmp % Mod;
	}
	printf("%lld\n", ans % Mod);
	fflush(stdout);
	return 0;
}
0