本文主要是介绍A - Memory and Crow CodeForces - 712A(水题),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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
题意: ai = bi - bi + 1 + bi + 2 - bi + 3…求a数组
思路: 相邻两项相加。
#include<iostream>
#include<stdio.h>
#include<map>
#include<cstring>
#include<algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <string>
using namespace std;const int maxn = 1e5 + 7;
int b[maxn];
int a[maxn];
int main()
{int n;scanf("%d",&n);for(int i = 1;i <= n;++i){scanf("%d",&a[i]);}for(int i = 1;i <= n;i++){printf("%d ",a[i] + a[i + 1]);}return 0;
}
这篇关于A - Memory and Crow CodeForces - 712A(水题)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!