結果
問題 | No.1958 Bit Game |
ユーザー |
👑 ![]() |
提出日時 | 2022-05-27 21:57:50 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,192 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 152,700 KB |
最終ジャッジ日時 | 2024-09-20 15:49:46 |
合計ジャッジ時間 | 7,200 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | TLE * 1 -- * 29 |
ソースコード
"""bitごとに解けばよいa0,a1,b0,b1個あった時1のORで1に0のANDで0になる1の方が後に来る確率だけ求めればok"""import sysfrom sys import stdinmod = 998244353def 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] * 18BZERO = [0] * 18for i in A:for j in range(18):if i % 2 == 1:AONE[j] += 1i //= 2for i in B:for j in range(18):if i % 2 == 0:BZERO[j] += 1i //= 2#print (AONE,BZERO)ans = 0N*=2for 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 = 0able = 1for i in range(N-1,-1,-1):if i % 2 == 0: #PCTnow += able * a1 * inv(X)able *= anotnow %= modable %= modelse:able *= bnotable %= modans += now * (2**bit)#print (a0,a1,b0,b1,now)ans %= modans *= pow(X*Y,N//2,mod)print (ans % mod)