题目收集
题目列表题单
返回列表

Cool P #1

CodeforcesP0023· 2000ms· 1024 MB· ZJU Summer 2026 Contest 2原题链接
线性基

创建于 2026/07/16 · 更新于 2026/07/16

题目描述

Given a sequence of nnn positive integers a1,a2,…,ana_1, a_2, \dots, a_na1​,a2​,…,an​.

For every prefix of length kkk (1≤k≤n1 \le k \le n1≤k≤n), consider all subsets of indices S⊆{1,2,…,k}S \subseteq \{1, 2, \dots, k\}S⊆{1,2,…,k}. Let P(S)=∏i∈SaiP(S) = \prod_{i \in S} a_iP(S)=∏i∈S​ai​. Count the number of subsets SSS for which P(S)P(S)P(S) is a perfect square.

The empty subset is allowed; its product is defined as P(∅)=1P(\varnothing) = 1P(∅)=1, which is a perfect square.

Two subsets are considered different if their sets of indices differ.

Since the answer can be large, output each count modulo 998244353998244353998244353.

输入格式

The first line contains a single integer nnn (1≤n≤5×1051 \le n \le 5 \times 10^51≤n≤5×105).

The second line contains nnn space-separated integers a1,a2,…,ana_1, a_2, \dots, a_na1​,a2​,…,an​ (1≤ai≤1061 \le a_i \le 10^61≤ai​≤106).

输出格式

Print exactly nnn integers in a single line, separated by spaces. The kkk-th integer (1≤k≤n1 \le k \le n1≤k≤n) should be the answer for the prefix of length kkk, modulo 998244353998244353998244353.

样例输入 #1

5
2 3 6 4 5

样例输出 #1

1
1
2
4
4

样例输入 #2

5
6 10 15 30 60

样例输出 #2

1
1
2
2
4