日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Memory and Crow

發布時間:2024/10/5 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Memory and Crow 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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.

分析可得bi=ai+ai+1

#include <stdio.h> #include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {int n;scanf("%d",&n);int i;int a[100000];for(i=0;i<n;i++){scanf("%d",&a[i]);}for(i=0;i<n-1;i++){printf("%d ",a[i]+a[i+1]);}printf("%d\n",a[i]);return 0; }

總結

以上是生活随笔為你收集整理的Memory and Crow的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。