A11368 | Cyclic Cipher
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 , 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  for all $k$ 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 $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}$ .
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  for all $k$ 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 $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}$ .
输入格式
The first line contains a single integer $n$ ().
The second line contains $n$ integers $b_{0},b_{1},...,b_{n-1}$ ().
The third line contains $n$ integers $c_{0},c_{1},...,c_{n-1}$ ().
It is guaranteed that all cyclic shifts of sequence $b_{i}$ are linearly independent.
The second line contains $n$ integers $b_{0},b_{1},...,b_{n-1}$ ().
The third line contains $n$ integers $c_{0},c_{1},...,c_{n-1}$ ().
It is guaranteed that all cyclic shifts of sequence $b_{i}$ are linearly independent.
输出格式
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$ .
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$ .
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted