#P7117. Mivik 卷积
Mivik 卷积
Description
Once upon a time, there was a Mivik who liked convolution. He defines the Mivik convolution of two polynomial functions and (both only related to ) as follows:
$$f\left(x\right)\otimes g\left(x\right)=\sum_{k=0}^{\deg f +\deg g}\max_{i\in [0,\deg f] \land j\in [0,\deg g]\land i+j=k}\left\{\left[x^i\right]f\left(x\right)+\left[x^j\right]g\left(x\right)\right\} x^k$$Here denotes the highest degree of , and denotes the coefficient of the term in .
Note that Mivik convolution is left-associative, i.e., .
Mivik defines a Mivik function as a function that can be written in the form , where and are both integers. For example, is a Mivik function, while is not.
Mivik also defines a function to be simple if and only if there exists a sequence of Mivik functions (of size ) such that:
$$f\left(x\right)=S_1\otimes S_2\otimes S_3\otimes\cdots\otimes S_{\left|S\right|}.$$Now Mivik gives you a polynomial function. Determine whether this function is simple. If it is, also output any possible .
Input Format
The first line contains a positive integer , representing the number of terms of this polynomial function.
The second line contains integers. From low degree to high degree, they represent the coefficients of this polynomial function. It is guaranteed that the highest-degree coefficient is non-zero.
Output Format
If this function is not simple, output one line nice.
Otherwise, first output one line simple, then output one line with the size of the sequence you construct. In the next lines, output the sequence you construct. Each line contains two integers and , describing a Mivik function .
3
2 3 3
simple
2
2 1
1 1
3
97 109 101
simple
2
54 42
47 55
9
9 9 8 2 4 4 3 5 3
nice
Hint
Sample Explanation #1
The given function can be obtained from .
Constraints
This problem uses bundled testdata.
For all data, , .
The detailed limits for each subtask are shown in the table below:
| Subtask ID | Score | |
|---|---|---|
| 1 | 5 | |
| 2 | ||
| 3 | 20 | |
| 4 | 30 | |
| 5 | 40 |
The input and output size of this problem is large. Please use fast I/O.
Translated by ChatGPT 5
京公网安备 11011102002149号