結果

問題 No.1958 Bit Game
ユーザー Drice27149Drice27149
提出日時 2022-05-27 21:42:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,406 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 56,916 KB
実行使用メモリ 18,412 KB
最終ジャッジ日時 2023-10-20 20:01:15
合計ジャッジ時間 7,683 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]);
    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++;
        }
        for (int fst = 1; fst <= n; fst++) {
            int way = power(a0 + a1, fst - 1) * 1ll * power(a0, n - fst) % mod * 1ll * a1 % mod;
            int mul = power(b0 + b1, fst - 1) * 1ll * power(b1, n - fst + 1) % mod;
            int conb = bit % mod * 1ll * way % mod * 1ll * mul % mod;
            add(ans, conb);
        }
    }
    printf("%d\n", ans);
    return 0;
}
0