No.1958 Bit Game
タグ : / 解いたユーザー数 111
作問者 :
PCTprobability
/ テスター :
👑
tute7627
Problem Statement
You are given integer sequences $A=(A_1,A_2,\dots,A_X),B=(B_1,B_2,\dots,B_Y)$.
Initially, there is an integer $P=0$. PCT-kun and tute-san repeat the following operation $N$ times.
- First, PCT-kun chooses $1$ element from $A$ uniformly at random. Let $Q$ be the chosen element, and replace $P$ with $P\ \mathrm{or}\ Q$.
- Next, tute-san chooses $1$ element from $B$ uniformly at random. Let $R$ be the chosen element, and replace $P$ with $P\ \mathrm{and}\ R$.
There are $(XY)^N$ possible ways to perform the $N$ operations. Over all of them, find the sum of the values of $P$ at the end of the operations, $\bmod 998244353$.
Here, $\mathrm{or}$ in the statement denotes bitwise OR, and $\mathrm{and}$ denotes bitwise AND.
Input
$N\ X\ Y$
$A_1\ A_2\ \dots\ A_{X}$
$B_1\ B_2\ \dots\ B_{Y}$
- All inputs are integers.
- $1 \le N \le 2 \times 10^5$
- $1 \le X,Y \le 2^{18}$
- $0 \le A_i,B_j < 2^{18}$
Output
Output the answer on $1$ line.
Sample
Sample 1
Input
1 1 2 1 2 3
Output
1
The operation is performed only $1$ time. If PCT-kun chooses $1$ and tute-kun chooses $2$, the value of $P$ at the end of the operations is $0$. If PCT-kun chooses $1$ and tute-kun chooses $3$, the value of $P$ at the end of the operations is $1$. Therefore, the answer is $0+1=1$.
Sample 2
Input
5 4 3 1 2 3 4 5 6 7
Output
1130844
Sample 3
Input
527 5 5 0 1 2 3 4 5 6 7 8 9
Output
248270434
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。