結果
問題 | No.1958 Bit Game |
ユーザー | Drice27149 |
提出日時 | 2022-05-27 21:47:20 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,097 ms / 2,000 ms |
コード長 | 1,777 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 61,228 KB |
実行使用メモリ | 19,392 KB |
最終ジャッジ日時 | 2023-10-20 20:06:37 |
合計ジャッジ時間 | 25,869 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,067 ms
19,392 KB |
testcase_01 | AC | 1,076 ms
19,392 KB |
testcase_02 | AC | 1,097 ms
19,392 KB |
testcase_03 | AC | 1,087 ms
19,392 KB |
testcase_04 | AC | 1,066 ms
19,392 KB |
testcase_05 | AC | 1,034 ms
19,392 KB |
testcase_06 | AC | 1,054 ms
19,392 KB |
testcase_07 | AC | 1,096 ms
19,392 KB |
testcase_08 | AC | 1,088 ms
19,392 KB |
testcase_09 | AC | 1,086 ms
19,392 KB |
testcase_10 | AC | 387 ms
8,012 KB |
testcase_11 | AC | 579 ms
11,172 KB |
testcase_12 | AC | 494 ms
10,524 KB |
testcase_13 | AC | 746 ms
13,828 KB |
testcase_14 | AC | 715 ms
13,224 KB |
testcase_15 | AC | 209 ms
7,560 KB |
testcase_16 | AC | 99 ms
5,448 KB |
testcase_17 | AC | 927 ms
16,468 KB |
testcase_18 | AC | 700 ms
13,664 KB |
testcase_19 | AC | 235 ms
7,296 KB |
testcase_20 | AC | 1,001 ms
16,952 KB |
testcase_21 | AC | 349 ms
9,236 KB |
testcase_22 | AC | 586 ms
11,020 KB |
testcase_23 | AC | 212 ms
6,352 KB |
testcase_24 | AC | 1,014 ms
17,288 KB |
testcase_25 | AC | 348 ms
8,112 KB |
testcase_26 | AC | 928 ms
15,380 KB |
testcase_27 | AC | 147 ms
6,528 KB |
testcase_28 | AC | 1,026 ms
16,996 KB |
testcase_29 | AC | 580 ms
10,488 KB |
testcase_30 | AC | 2 ms
4,348 KB |
testcase_31 | AC | 1 ms
4,348 KB |
testcase_32 | AC | 4 ms
4,348 KB |
ソースコード
#include <cstdio> #include <vector> #include <algorithm> #include <functional> using namespace std; const int mod = 998244353; void add(int& u, int v) { u += v; if (u >= mod) u -= mod; } void sub(int& u, int v) { u -= v; if (u < 0) u += mod; } int power(int a, int b) { int res = 1; while (b) { if (b % 2) res = res * 1ll * a % mod; a = a * 1ll * a % mod; b /= 2; } return res; } int main() { int n, x, y; scanf("%d%d%d", &n, &x, &y); vector<long long> a(x); vector<long long> b(y); for (int i = 0; i < x; i++) scanf("%lld", &a[i]); for (int i = 0; i < y; i++) scanf("%lld", &b[i]); vector<int> px(n + 1, 1); vector<int> py(n + 1, 1); for (int i = 1; i <= n; i++) { px[i] = px[i - 1] * 1ll * x % mod; py[i] = py[i - 1] * 1ll * y % mod; } int ans = 0; for (int it = 0; it <= 60; it++) { long long bit = 1ll << it; int a0 = 0, a1 = 0; int b0 = 0, b1 = 0; for (int i = 0; i < x; i++) { if (a[i] & bit) a1++; else a0++; } for (int i = 0; i < y; i++) { if (b[i] & bit) b1++; else b0++; } vector<vector<int>> pw(n + 1, vector<int> (2, 1)); for (int i = 1; i <= n; i++) { pw[i][0] = pw[i - 1][0] * 1ll * a0 % mod; pw[i][1] = pw[i - 1][1] * 1ll * b1 % mod; } for (int fst = 1; fst <= n; fst++) { int way = px[fst - 1] * 1ll * pw[n - fst][0] % mod * 1ll * a1 % mod; int mul = py[fst - 1] * 1ll * pw[n - fst + 1][1] % mod; int conb = bit % mod * 1ll * way % mod * 1ll * mul % mod; add(ans, conb); } } printf("%d\n", ans); return 0; }