QOJ.ac

QOJ

時間限制: 2 s 記憶體限制: 2048 MB 總分: 100 可 Hack ✓

#547. Boyer-Moore Algorithm

统计

Given $f_1, f_2, \dots, f_n$, find the shortest linear recurrence sequence $f_n = \sum_{i=1}^k f_{n-i}c_i$ (for $n \geq k$). All calculations are performed modulo $998244353$.

Input

The first line contains an integer $n$.

The next line contains $n$ integers $f_1, f_2, \dots, f_n$.

Output

The first line contains an integer $k$.

The next line contains $k$ integers $c_1, c_2, \dots, c_k$, representing the answer.

If there are multiple valid sequences $c$, you may output any one of them.

Examples

Input 1

2
1 1

Output 1

1
1

Input 2

6
1 1 4 5 1 4

Output 2

3
781234712 737832781 130205788

Subtasks

For all test cases, $0 \le n \leq 10^4$ and $0 \le f_i < 998\,244\,353$.

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.