Back To School '18: An FFT Problem

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 128M

Author:
Problem type

To prepare for the upcoming school year, Richard has bought N books for his English class. Each book is assigned a value, ai, Richard's willingness to read that book.

Richard wants to choose k of the N books and calculate his willingness to read those k books. The willingness to read those k books is the product of the willingness to read each individual book. For example, if he bought books of value a=[2,5,7,9,13], and he chose k=3 books with indices 1,2,4, the willingness to read those books would be a1a2a4=259=90.

Richard wants the sum of the willingness of all distinct combinations of k books for all values of k (1kN).

However, since Richard does not like large numbers, he wants each sum modulo 998244353.

Two combinations are considered distinct if the indices of the books chosen are different, regardless of the values of the books.

Input Specification

The first line of input will contain a single integer N (1N2000), the number of books that Richard bought.

The second line of input will contain N space-separated integers, the ith integer representing ai (|ai|109), the value of each book.

Output Specification

On one line, print N space-separated integers, the kth integer representing the sum of the willingness of all distinct combinations of choosing k books, modulo 998244353.

We define A modulo B in the 2 equivalent ways:

  1. Taking the remainder of A÷B, adding B if the result is negative.
  2. Subtracting B from A, or adding B to A, until A is in the interval [0,B).

It may or may not help to know that 998244353=119223+1.

Constraints

Subtask 1 [5%]

N10

Subtask 2 [10%]

N20

Subtask 3 [35%]

|ai|103

Subtask 4 [50%]

No additional constraints.

Sample Input 1

Copy
4
1 2 2 3

Sample Output 1

Copy
8 23 28 12

Explanation for Sample Output 1

N=4, a=[1,2,2,3].


There are 4 distinct combinations to read 1 book:

a1=1

a2=2

a3=2

a4=3

Their sum is 8.


There are 6 distinct combinations to read 2 books.

a1a2=12=2

a1a3=12=2

a1a4=13=3

a2a3=22=4

a2a4=23=6

a3a4=23=6

Their sum is 23.


There are 4 distinct combinations of reading 3 books.

a1a2a3=122=4

a1a2a4=123=6

a1a3a4=123=6

a2a3a4=223=12

Their sum is 28.


The only distinct combination of reading 4 books is a1a2a3a4=1223=12.

Sample Input 2

Copy
3
-1 -1 -1

Sample Output 2

Copy
998244350 3 998244352

Comments

There are no comments at the moment.