A. Memory and Crow
time limit per test:2 seconds
memory limit per test:256 megabytes
input:standard input
output:standard output

There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure:

  • The crow sets ai initially 0.
  • The crow then adds bi to ai, subtracts bi + 1, adds the bi + 2 number, and so on until the n'th number. Thus, ai = bi - bi + 1 + bi + 2 - bi + 3....

Memory gives you the values a1, a2, ..., an, and he now wants you to find the initial numbers b1, b2, ..., bn written in the row? Can you do it?

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of integers written in the row.

The next line contains n, the i'th of which is ai ( - 109 ≤ ai ≤ 109) — the value of the i'th number.

Output

Print n integers corresponding to the sequence b1, b2, ..., bn. It's guaranteed that the answer is unique and fits in 32-bit integer type.

Examples
Input
5
6 -4 8 -2 3
Output
2 4 6 1 3 
Input
5
3 -2 -1 5 6
Output
1 -3 4 11 6 
Note

In the first sample test, the crows report the numbers 6, - 4, 8, - 2, and 3 when he starts at indices 1, 2, 3, 4 and 5 respectively. It is easy to check that the sequence 2 4 6 1 3 satisfies the reports. For example, 6 = 2 - 4 + 6 - 1 + 3, and  - 4 = 4 - 6 + 1 - 3.

In the second sample test, the sequence 1,  - 3, 4, 11, 6 satisfies the reports. For example, 5 = 11 - 6 and 6 = 6.

解题思路:

【题意】
有n个数b1, b2, ..., bn

a1, a2, ..., an是通过等式ai = bi - bi + 1 + bi + 2 - bi + 3....(±)bn得到的

现给你a1, a2, ..., an这n个数,问b1, b2, ..., bn是多少
【类型】
公式推导
【分析】

由此可见,数组b中的第i项等于数组a中的第i项与第i+1项之和

特别地,数组b中的第n项等于数组a中的第n项

【时间复杂度&&优化】
O(n)

题目链接→Codeforces Problem 712A Memory and Crow

 #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,a,b;
while(cin>>n)
{
for(int i=;i<=n;i++)
{
cin>>a;
if(i>)
cout<<a+b<<" ";
b=a;
}
cout<<a<<endl;
}
return ;
}

Codeforce 712A Memory and Crow的更多相关文章

  1. codeforces 712A. Memory and Crow

    题目链接:http://codeforces.com/problemset/problem/712/A 题目大意: 给你一个数字系列,求其满足条件的一个序列. 条件为: ai = bi - bi +  ...

  2. CodeForces 712A Memory and Crow (水题)

    题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 析:很容易看出来,bi = ai ...

  3. codeforces 712A A. Memory and Crow(水题)

    题目链接: A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  4. Codeforces Round #370 (Div. 2) A. Memory and Crow 水题

    A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integer ...

  5. codeforces 712A. Memory and Crow

    2019-05-18 08:48:27 加油,加油,坚持!!! 这道题我没有想出公式推导,只是按照模拟题来做,第5个样例超时 样例超时,方法错误 https://www.cnblogs.com/ECJ ...

  6. ECJTUACM16 Winter vacation training #4 题解&源码

    A......................................................................................... 题目链接→Code ...

  7. CSUST 8.4 早训

    ## Problem A A - Memory and Crow CodeForces - 712A 题意: 分析可得bi=ai+ai+1 题解: 分析可得bi=ai+ai+1 C++版本一 #inc ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. Codeforces Round #370 (Div. 2) A B C 水 模拟 贪心

    A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. 如何使用XE2及更高版本中提供的自定义皮肤(样式)功能

    源:如何使用XE2及更高版本中提供的自定义皮肤(样式)功能 1. 制作样式文件: 点击 XE2+ 的 IDE 菜单上的 Tools-->Bitmap Style Designer, 打开设计器. ...

  2. Android之ListView的快速滑动模式:fastScrollEnabled以及滑块的自定义

    http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2014/0917/1690.html http://blog.csdn.net/xyang ...

  3. [iOS] 响应式编程开发-ReactiveCocoa(二)

    RAC实现图片下载功能 在实现异步RAC下载图片的过程中,需要注意以下几点: • 通过 NSURLConnection 对象的 +(RACSignal *)rac_sendAsynchronousRe ...

  4. linux shell 之if-------用if做判断

    综合网络,略有修改, 一 简介 1 字符串判断 str1 = str2 当两个串有相同内容.长度时为真  str1 != str2 当串str1和str2不等时为真  -n str1 当串的长度大于0 ...

  5. iOS探究UITableView的内部代码,仿UITableView自定义

    大家都知道UITableView,最经典在于循环利用,这里我自己模仿UITableView循环利用,写了一套自己的TableView实现方案,希望大家看了我的文章,循环利用思想有显著提升. 研究UIT ...

  6. iOS 简易环形进度条

    demo下载地址:https://github.com/haozheMa/LoopProgressDemo/tree/master ViewController中的代码 #import "V ...

  7. 图片拉伸iOS

    - (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight: (NSInteger)topCa ...

  8. LPC1788的外部中断和GPIO中断

    首先是gpio中断,这一点和1768不同,1768使用的中断时和eint3共用中断通道,到了1788,专门为gpio开辟了中断 #ifndef __JOYPAD_H_ #define __JOYPAD ...

  9. Delphi调用Android的.so文件(转)

    原地址:http://zhidao.baidu.com/link?url=fzqefMM44ljXA5BnAbkX44SapCUteyzlXFvGLKvukBivm9AB-w39P_h7eX1ty-G ...

  10. 设置MyEclipse黑色主题背景

    设置MyEclipse黑色主题背景 1. 下载 http://eclipsecolorthemes.org/  看哪个合适直接点击进入, 下载右边的epf 2. 下载完成...打开myeclipse. ...