QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#1692. Necklace in a Dream

统计

There are several types of gemstones, where there are $a_k$ types of gemstones with weight $k$. You want to find, for each $w \le n$, the number of necklaces made of these gemstones such that the necklace contains at least $2$ gemstones, every pair of adjacent gemstones belongs to different types, and the total weight of the necklace is $w$. The answer should be taken modulo $998244353$.

Note:

  • The first gemstone and the last gemstone of the necklace must also belong to different types.
  • If two configurations can be transformed into each other by rotation or reflection, they are still considered different configurations.

Input

The first line contains a positive integer $n$.

The next line contains $n$ integers, where the $k$-th number represents $a_k$.

Output

Output $n + 1$ integers, representing the number of configurations for $w=0, 1, \dots, n$ respectively.

Examples

Input 1

5
2 1 0 1 0

Output 1

0 0 2 4 8 12

Note 1

The following multiplication signs can be considered as rotation generation:

$$ 2:[1,1']\times 2\\ 3:[1,2]\times 2,[1',2] \times 2\\ 4:[1,1',1,1'] \times 2,[1,1',2]\times 3,[1',1,2]\times 3\\ 5:[1,4]\times 2, [1',4]\times 2, [1,1',1,2]\times 4, [1',1,1',2]\times 4 $$

Input 2

See the provided files.

Output 2

See the provided files.

Constraints

For $100\%$ of the data, it is guaranteed that $2 \le n \le 10^5$ and $0 \le a_i < 998244353$.

Test Case ID$n$Special Constraints
$1$$\le 8$
$2$$\le 50$
$3$$\le 10^5$Only gemstones of weight $1$ exist
$4$$\le 3\times 10^2$
$5$
$6$
$7$$\le 3\times 10^3$
$8$
$9$$\le 10^5$
$10$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.