AtCoder Regular Contest 185
E
Adjacent GCD
AtCoder
⌀ 2185
原题
← D→
翻译中…

Problem Statement

翻译中…

Define the score of a sequence of positive integers $B = (B_1, B_2, \dots, B_k)$ as $\displaystyle \sum_{i=1}^{k-1} \gcd(B_i, B_{i+1})$. Given a sequence of positive integers $A = (A_1, A_2, \dots, A_N)$, solve the following problem for $m = 1, 2, \dots, N$.

翻译中…
  • There are $2^m - 1$ non-empty subsequences of the sequence $(A_1, A_2, \dots, A_m)$. Find the sum of the scores of all those subsequences, modulo $998244353$. Two subsequences are distinguished if they are taken from different positions in the sequence, even if they coincide as sequences.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 5 \times 10^5$
  • $1 \leq A_i \leq 10^5$
  • All input values are integers.
翻译中…

Input

翻译中…

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

翻译中…

N
A_1 A_2 \dots A_N

翻译中…

Output

翻译中…

Print $N$ lines. The $i$-th line should contain the answer for $m = i$.

翻译中…

样例

Input #1
3
9 6 4
Output #1
0
3
11
Consider the case $m = 3$. Here are the non-empty subsequences of $(A_1, A_2, A_3) = (9, 6, 4)$ and their scores. - $(9)$: Score is $0$. - $(6)$: Score is $0$. - $(4)$: Score is $0$. - $(9, 6)$: Score is $\gcd(9, 6) = 3$. - $(9, 4)$: Score is $\gcd(9, 4) = 1$. - $(6, 4)$: Score is $\gcd(6, 4) = 2$. - $(9, 6, 4)$: Score is $\gcd(9, 6) + \gcd(6, 4) = 3 + 2 = 5$. Therefore, the answer for $m = 3$ is $0 + 0 + 0 + 3 + 1 + 2 + 5 = 11$.
Input #2
5
3 8 12 6 9
Output #2
0
1
13
57
155
Input #3
10
47718 21994 74148 76721 98917 73766 29598 59035 69293 29127
Output #3
0
2
14
35
97
372
866
1859
4273
43287
题目信息
题号
arc185_e
时间限制
2 s
内存限制
1024 MB

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