AtCoder Regular Contest 205 (Div. 2)
E
Subset Product Problem
AtCoder
⌀ 2102
原题
← D→
翻译中…

Problem Statement

翻译中…

You are given a length-$N$ sequence of non-negative integers $A=(A_1,A_2,\ldots,A_N)$.

翻译中…

For $k=1,2,\ldots,N$, solve the following problem.

翻译中…
  • Find the product, modulo $998244353$, of $A_i$ for all integers $i$ between $1$ and $k$, inclusive, such that the bitwise $\mathrm{OR}$ operation of $A_i$ and $A_k$ equals $A_k$.
翻译中…

What is bitwise $\mathrm{OR}$ operation? The bitwise $\mathrm{OR}$ of non-negative integers $X$ and $Y$, denoted $X\ \mathrm{OR}\ Y$, is defined as follows. When $X\ \mathrm{OR}\ Y$ is written in binary, the digit at the $2^k$ $(k \geq 0)$ place is $1$ if at least one of the digits at the $2^k$ place when $X$ and $Y$ are written in binary is $1$, and $0$ otherwise. For example, $3\ \mathrm{OR}\ 5 = 7$ (in binary: $011\ \mathrm{OR}\ 101 = 111$).

翻译中…

Constraints

翻译中…
  • $1\le N\le 4\times 10^5$
  • $0\le A_i < 2^{20}$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \ldots A_N

翻译中…

Output

翻译中…

Output $N$ lines.

翻译中…

The $i$-th line $(1\le i\le N)$ should contain the answer for the case $k=i$.

翻译中…

样例

Input #1
4
1 2 3 5
Output #1
1
2
6
5
- When $k=1$: For $i=1$, the bitwise $\mathrm{OR}$ operation of $A_i$ and $A_k$ is $1$. Therefore, the answer for the case $k=1$ is $A_1=1$. - When $k=2$: For $i=1,2$, the bitwise $\mathrm{OR}$ operation of $A_i$ and $A_k$ is $3,2$, respectively. Therefore, the answer for the case $k=2$ is $A_2=2$. - When $k=3$: For $i=1,2,3$, the bitwise $\mathrm{OR}$ operation of $A_i$ and $A_k$ is all $3$. Therefore, the answer for the case $k=3$ is $A_1\times A_2\times A_3=6$. - When $k=4$: For $i=1,2,3,4$, the bitwise $\mathrm{OR}$ operation of $A_i$ and $A_k$ is $5,7,7,5$, respectively. Therefore, the answer for the case $k=4$ is $A_1\times A_4=5$.
Input #2
9
3 1 4 1 5 9 2 6 5
Output #2
3
1
4
1
20
9
2
48
100
Input #3
12
437926 528156 284664 1038330 692060 720863 602077 1027766 868190 532252 982711 876446
Output #3
437926
528156
284664
94842632
158208162
985930968
548875758
875494466
345599613
605424119
111381243
768586512
题目信息
题号
arc205_e
时间限制
6 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。