結果
| 問題 |
No.1958 Bit Game
|
| コンテスト | |
| ユーザー |
SidewaysOwl
|
| 提出日時 | 2022-05-28 04:38:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,813 ms / 2,000 ms |
| コード長 | 804 bytes |
| コンパイル時間 | 473 ms |
| コンパイル使用メモリ | 82,636 KB |
| 実行使用メモリ | 144,100 KB |
| 最終ジャッジ日時 | 2025-03-27 19:35:07 |
| 合計ジャッジ時間 | 43,342 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
n,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
mod = 998244353
cul = lambda s:pow(s,mod-2,mod)
ans = 0
for i in range(18):
a1,a0,b1,b0 = 0,0,0,0
for j in range(x):
if a[j] & (1 << i):a1 += 1
else:a0 += 1
for j in range(y):
if b[j] & (1 << i):b1 += 1
else:b0 += 1
dp = [1,0]
a0x = cul(x) * a0
a1x = cul(x) * a1
b0y = cul(y) * b0
b1y = cul(y) * b1
for j in range(n):
n_dp = [0,0]
n_dp[0] += dp[0] * (a0x + a1x*b0y)
n_dp[0] += dp[1] * b0y
n_dp[1] += dp[0] * a1x*b1y
n_dp[1] += dp[1] * b1y
n_dp[0] %= mod
n_dp[1] %= mod
dp = n_dp
# print(dp,i)
ans += pow(x*y,n,mod) * pow(2,i,mod)*dp[1]
ans %= mod
print(ans)
SidewaysOwl