結果

問題 No.1958 Bit Game
ユーザー 8nd5t8nd5t
提出日時 2022-05-27 22:13:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,893 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,764 KB
実行使用メモリ 166,080 KB
最終ジャッジ日時 2023-10-20 20:21:41
合計ジャッジ時間 7,273 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right
import sys,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split()))
def err(x): print(x); exit()

class Combination:
    """
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

mod = 998244353
m = 18
n,x,y = inpl()
a = inpl()
b = inpl()
res = 0
p = [1]
for i in range(n):
    p.append(p[-1]*x*y%mod)
for d in range(m):
    cnta = cntb = 0
    ans = 0
    for aa in a:
        if (aa>>d)%2:
            cnta += 1
    for bb in b:
        if (bb>>d)%2:
            cntb += 1
    if cnta == 0 or cntb == 0:
        continue
    for i in range(n):
        ans += p[i]*cnta*pow(cntb,n-i,mod)*pow(x-cnta,n-i-1,mod)
        ans %= mod
    res += ans*pow(2,d,mod)
    res %= mod
print(res)
0