CF901E.Cyclic Cipher

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Vorpal is very selective, so the key should be such a sequence bib_{i} , that its cyclic shifts are linearly independent, that is, there is no non-zero set of coefficients x0,x1,...,xn1x_{0},x_{1},...,x_{n-1} , such that for all kk at the same time.

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

In other words, you are to compute the quadratic deviation between each cyclic shift of bib_{i} and the sequence aia_{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 cic_{i} and bib_{i} . You are to find all suitable sequences aia_{i} .

输入格式

The first line contains a single integer nn ().

The second line contains nn integers b0,b1,...,bn1b_{0},b_{1},...,b_{n-1} ().

The third line contains nn integers c0,c1,...,cn1c_{0},c_{1},...,c_{n-1} ().

It is guaranteed that all cyclic shifts of sequence bib_{i} are linearly independent.

输出格式

In the first line print a single integer kk — the number of sequences aia_{i} , such that after encrypting them with key bib_{i} you get the sequence cic_{i} .

After that in each of kk next lines print nn integers a0,a1,...,an1a_{0},a_{1},...,a_{n-1} . Print the sequences in lexicographical order.

Note that kk could be equal to 00 .

输入输出样例

  • 输入#1

    1
    1
    0
    

    输出#1

    1
    1
    
  • 输入#2

    1
    100
    81
    

    输出#2

    2
    91
    109
    
  • 输入#3

    3
    1 1 3
    165 185 197
    

    输出#3

    2
    -6 -9 -1
    8 5 13
    
首页