結果

問題 No.1958 Bit Game
ユーザー 👑 ygussanyygussany
提出日時 2022-05-27 21:44:11
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1,655 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 33,032 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 20:03:52
合計ジャッジ時間 36,240 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,588 ms
4,348 KB
testcase_01 AC 1,586 ms
4,348 KB
testcase_02 AC 1,589 ms
4,348 KB
testcase_03 AC 1,573 ms
4,348 KB
testcase_04 AC 1,575 ms
4,348 KB
testcase_05 AC 1,655 ms
4,348 KB
testcase_06 AC 1,578 ms
4,348 KB
testcase_07 AC 1,586 ms
4,348 KB
testcase_08 AC 1,583 ms
4,348 KB
testcase_09 AC 1,585 ms
4,348 KB
testcase_10 AC 491 ms
4,348 KB
testcase_11 AC 778 ms
4,348 KB
testcase_12 AC 618 ms
4,348 KB
testcase_13 AC 1,080 ms
4,348 KB
testcase_14 AC 1,009 ms
4,348 KB
testcase_15 AC 215 ms
4,348 KB
testcase_16 AC 89 ms
4,348 KB
testcase_17 AC 1,267 ms
4,348 KB
testcase_18 AC 947 ms
4,348 KB
testcase_19 AC 250 ms
4,348 KB
testcase_20 AC 1,526 ms
4,348 KB
testcase_21 AC 400 ms
4,348 KB
testcase_22 AC 882 ms
4,348 KB
testcase_23 AC 245 ms
4,348 KB
testcase_24 AC 1,463 ms
4,348 KB
testcase_25 AC 452 ms
4,348 KB
testcase_26 AC 1,371 ms
4,348 KB
testcase_27 AC 144 ms
4,348 KB
testcase_28 AC 1,552 ms
4,348 KB
testcase_29 AC 799 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[262144], B[262144];
	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