A1109 | [COCI-2007_2008-contest2]#3 KEMIJA
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Instead of paying attention in chemistry class, Luka is killing time playing with numbers again. This time, he wrote N positive integers so that they form a ring (circle). After that he formed a new ring by adding to each number its two neighbours.
The teacher noticed this and took away the first piece of paper, with the original ring. This did not trouble Luka much because he knows he can use the other ring to reconstruct the original.
Write a program that solves Luka's problem.
The teacher noticed this and took away the first piece of paper, with the original ring. This did not trouble Luka much because he knows he can use the other ring to reconstruct the original.
Write a program that solves Luka's problem.
输入格式
The first line contains the integer N (3 ≤ N ≤ 10000), the number of integers in the rings.
Each of the following N lines contains an integer less than 109 (one billion). These numbers, in order,
form the second ring.
The input will be such that a solution, although not necessarily unique, will always exist.
Each of the following N lines contains an integer less than 109 (one billion). These numbers, in order,
form the second ring.
The input will be such that a solution, although not necessarily unique, will always exist.
输出格式
Output the original ring on N lines. The numbers must be positive.
Rotating the ring is not allowed. For example, the sum of the first three output numbers must be equal to the second number in the input ring.
Note: The solution need not be unique.
Rotating the ring is not allowed. For example, the sum of the first three output numbers must be equal to the second number in the input ring.
Note: The solution need not be unique.
输入输出样例
输入 #1
3 5 5 5
输出 #1
2 1 2
输入 #2
4 20 15 17 14
输出 #2
5 8 2 7
输入 #3
5 7 8 9 10 11
输出 #3
4 1 3 5 2
In test cases worth 70% of points, N will be less than 100.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted