Description

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.

题意:告诉你 ai = bi - bi + 1 + bi + 2 - bi + 3 ,和b的序列,求a的序列

解法:反过来就好了,会发现规律都是相加

#include<bits/stdc++.h>
using namespace std;
int a[100005];
int n,m;
int b[100005];
int main()
{
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
int cot=1;
a[n+1]=0;
for(int i=n;i>=1;i--)
{
b[cot++]=a[i+1]+a[i];
}
for(int i=cot-1;i>=1;i--)
{
cout<<b[i]<<endl;
}
return 0;
}

  

Codeforces Round #370 (Div. 2) A的更多相关文章

  1. Codeforces Round #370 (Div. 2) E. Memory and Casinos (数学&&概率&&线段树)

    题目链接: http://codeforces.com/contest/712/problem/E 题目大意: 一条直线上有n格,在第i格有pi的可能性向右走一格,1-pi的可能性向左走一格,有2中操 ...

  2. Codeforces Round #370 (Div. 2) E. Memory and Casinos 线段树

    E. Memory and Casinos 题目连接: http://codeforces.com/contest/712/problem/E Description There are n casi ...

  3. Codeforces Round #370 (Div. 2)C. Memory and De-Evolution 贪心

    地址:http://codeforces.com/problemset/problem/712/C 题目: C. Memory and De-Evolution time limit per test ...

  4. Codeforces Round #370 (Div. 2)B. Memory and Trident

    地址:http://codeforces.com/problemset/problem/712/B 题目: B. Memory and Trident time limit per test 2 se ...

  5. Codeforces Round #370 (Div. 2) D. Memory and Scores 动态规划

    D. Memory and Scores 题目连接: http://codeforces.com/contest/712/problem/D Description Memory and his fr ...

  6. Codeforces Round #370 (Div. 2) C. Memory and De-Evolution 水题

    C. Memory and De-Evolution 题目连接: http://codeforces.com/contest/712/problem/C Description Memory is n ...

  7. Codeforces Round #370 (Div. 2) B. Memory and Trident 水题

    B. Memory and Trident 题目连接: http://codeforces.com/contest/712/problem/B Description Memory is perfor ...

  8. 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 ...

  9. Codeforces Round #370(div 2)

    A B C :=w= D:两个人得分互不影响很关键 一种是f[i][j]表示前i轮,分差为j的方案数 明显有f[i][j]=f[i-1][j-2k]+2*f[i-1][j-2k+1]+...+(2k+ ...

  10. Codeforces Round #370 (Div. 2)(简单逻辑,比较水)

    C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input s ...

随机推荐

  1. 转:python webdriver API 之浏览器多窗口处理

    有时候我们在测试一个 web 应用时会出现多个浏览器窗口的情况,在 selenium1.0 中这个问题比较难处理.webdriver 提供了相关相方法可以很轻松的在多个窗口之间切换并操作不同窗口上的元 ...

  2. struts局部、全局类型转换器

    第01步:编写bean package com.self.bean; import java.util.Date; public class User { private Date birthday ...

  3. Android -- 自定义View小Demo,关于Path类的使用(一)

    1,在我们知道自定义view中onDraw()方法是用于绘制图形的,而Path类则是其中的一个重要的类,如下图效果: 代码也没有什么难度,直接贴出来吧 @Override protected void ...

  4. mysql 导出过长的数字列时变科学计数法问题解决办法

    --mysql 导出数据时,  数字类型的列如果位数过长,变为科学技术发问题  concat('\t',a.IDCARD_NO)     例子: select   concat('\t',a.IDCA ...

  5. 夺命雷公狗—angularjs—5—ng-switch的用法实现下拉更换板块的实现

    这个方法一般都会是和别的块状元素进行绑定同时使用的,废话不多说,直接上代码: <!doctype html> <html lang="en"> <he ...

  6. thinphp讲解(三)——空操作、空控制器、跨控制器、命名空间

    一.“空操作”本质意思:一个对象(控制器)调用本身不存在的操作方法 一般网站处于安全考虑不给用户提示任何错误信息 在tp里面控制器controller.class.php里有个_call()方法 所以 ...

  7. HTTP请求流程(一)----流程简介

    最近一直在研究如何让asp.net实现上传大文件的功能,所以都没怎么写技术类的文章了.可惜的是至今还没研究出来,惭愧~~~.不过因为这样,也了解了一下http消息请求的大致过程.我就先简单介绍下,然后 ...

  8. redis面试题总结

    1. 使用redis有哪些好处? (1) 速度快,因为数据存在内存中,类似于HashMap,HashMap的优势就是查找和操作的时间复杂度都是O(1) (2) 支持丰富数据类型,支持string,li ...

  9. 影响SQL server性能的关键

    一.逻辑数据库和表的设计数据库的逻辑设计.包括表与表之间的关系是优化关系型数据库性能的核心.一个好的逻辑数据库设计可以为优化数据库和应用程序打下良好的基础.   标准化的数据库逻辑设计包括用多的.有相 ...

  10. 2014.12.05(解决eclipse的adb打不开)

    一.问题如下图所示 The connection to adb is down, and a severe error has occured.You must restart adb and Ecl ...