Codeforces Round 453 (Div. 1)
E
Cyclic Cipher
Codeforces
3300
原题
← D→
翻译中…

image

翻译中…

Senor Vorpal Kickass'o invented an innovative method to encrypt integer sequences of length $*n*$. To encrypt a sequence, one has to choose a secret sequence image, that acts as a key.

翻译中…

Vorpal is very selective, so the key should be such a sequence $*b*_{*i*}$, that its cyclic shifts are linearly independent, that is, there is no non-zero set of coefficients $*x*_{0}, *x*_{1}, ..., *x*_{*n* - 1}$, such that image for all $*k*$ at the same time.

翻译中…

After that for a sequence image you should build the following cipher:

翻译中…

image

翻译中…

In other words, you are to compute the quadratic deviation between each cyclic shift of $*b*_{*i*}$ and the sequence $*a*_{*i*}$. The resulting sequence is the Kickass's cipher. The cipher is in development right now and Vorpal wants to decipher a sequence after it has been encrypted. You are to solve this problem for him. You are given sequences $*c*_{*i*}$ and $*b*_{*i*}$. You are to find all suitable sequences $*a*_{*i*}$.

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ (image).

翻译中…

The second line contains $*n*$ integers $*b*_{0}, *b*_{1}, ..., *b*_{*n* - 1}$ (image).

翻译中…

The third line contains $*n*$ integers $*c*_{0}, *c*_{1}, ..., *c*_{*n* - 1}$ (image).

翻译中…

It is guaranteed that all cyclic shifts of sequence $*b*_{*i*}$ are linearly independent.

翻译中…

Output

翻译中…

In the first line print a single integer $*k*$ — the number of sequences $*a*_{*i*}$, such that after encrypting them with key $*b*_{*i*}$ you get the sequence $*c*_{*i*}$.

翻译中…

After that in each of $*k*$ next lines print $*n*$ integers $*a*_{0}, *a*_{1}, ..., *a*_{*n* - 1}$. Print the sequences in lexicographical order.

翻译中…

Note that $*k*$ could be equal to $0$.

翻译中…

样例

Input #1
1
1
0
Output #1
1
1
InputCopy OutputCopy
Input #2
1
100
81
Output #2
2
91
109
InputCopy OutputCopy
Input #3
3
1 1 3
165 185 197
Output #3
2
-6 -9 -1
8 5 13
InputCopy OutputCopy
题目信息
题号
901E
时间限制
5 s
内存限制
256 MB
标签
FFT
数学

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