結果

問題 No.1958 Bit Game
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-05-27 21:57:50
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,192 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 152,824 KB
最終ジャッジ日時 2023-10-20 20:13:15
合計ジャッジ時間 7,449 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

"""

bitごとに解けばよい

a0,a1,b0,b1
個あった時

1のORで1に
0のANDで0になる

1の方が後に来る確率だけ求めればok
 

"""

import sys
from sys import stdin

mod = 998244353
def inv(x):
    return pow(x,mod-2,mod)

N,X,Y = map(int,stdin.readline().split())

A = list(map(int,stdin.readline().split()))
B = list(map(int,stdin.readline().split()))

AONE  = [0] * 18
BZERO = [0] * 18

for i in A:
    for j in range(18):
        if i % 2 == 1:
            AONE[j] += 1
        i //= 2

for i in B:
    for j in range(18):
        if i % 2 == 0:
            BZERO[j] += 1
        i //= 2

#print (AONE,BZERO)

ans = 0
N*=2

for bit in range(18):

    a0,a1,b0,b1 = X-AONE[bit] , AONE[bit] , BZERO[bit] , Y - BZERO[bit]

    anot = a0 * inv(X)
    bnot = b1 * inv(Y)
    
    now = 0

    able = 1
    for i in range(N-1,-1,-1):

        if i % 2 == 0: #PCT
            now += able * a1 * inv(X)
            able *= anot
            now %= mod
            able %= mod
        else:
            able *= bnot
            able %= mod

    ans += now * (2**bit)

    #print (a0,a1,b0,b1,now)
    
    ans %= mod

ans *= pow(X*Y,N//2,mod)

print (ans % mod)
        
0