結果

問題 No.1958 Bit Game
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-05-27 21:59:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,250 ms / 2,000 ms
コード長 1,215 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 141,264 KB
最終ジャッジ日時 2023-10-20 20:15:51
合計ジャッジ時間 28,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,225 ms
141,264 KB
testcase_01 AC 1,238 ms
140,456 KB
testcase_02 AC 1,250 ms
140,472 KB
testcase_03 AC 1,247 ms
140,460 KB
testcase_04 AC 1,227 ms
140,476 KB
testcase_05 AC 1,249 ms
140,460 KB
testcase_06 AC 1,238 ms
140,724 KB
testcase_07 AC 1,225 ms
140,456 KB
testcase_08 AC 1,232 ms
140,456 KB
testcase_09 AC 1,245 ms
140,456 KB
testcase_10 AC 435 ms
88,332 KB
testcase_11 AC 646 ms
105,128 KB
testcase_12 AC 591 ms
112,476 KB
testcase_13 AC 846 ms
105,416 KB
testcase_14 AC 810 ms
103,576 KB
testcase_15 AC 336 ms
108,300 KB
testcase_16 AC 212 ms
102,024 KB
testcase_17 AC 1,020 ms
111,564 KB
testcase_18 AC 806 ms
112,416 KB
testcase_19 AC 350 ms
108,596 KB
testcase_20 AC 1,102 ms
101,820 KB
testcase_21 AC 465 ms
112,572 KB
testcase_22 AC 677 ms
88,584 KB
testcase_23 AC 301 ms
100,284 KB
testcase_24 AC 1,099 ms
119,544 KB
testcase_25 AC 427 ms
103,512 KB
testcase_26 AC 981 ms
106,892 KB
testcase_27 AC 277 ms
104,836 KB
testcase_28 AC 1,101 ms
106,760 KB
testcase_29 AC 577 ms
97,624 KB
testcase_30 AC 37 ms
53,400 KB
testcase_31 AC 37 ms
53,400 KB
testcase_32 AC 46 ms
59,628 KB
権限があれば一括ダウンロードができます

ソースコード

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

Xinv = inv(X)
Yinv = inv(Y)

for bit in range(18):

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

    anot = a0 * Xinv
    bnot = b1 * Yinv
    
    now = 0

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

        if i % 2 == 0: #PCT
            now += able * a1 * Xinv
            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