712A - Memory and Crow - CodeForces Solution


implementation math *800

Please click on ads to support us..

Python Code:

n=int(input())
l = [*map(int,input().split())]+[0]
print(*[*(l[i]+l[i+1] for i in range(n))])

C++ Code:

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair //(f, s);
#define F first
#define S second
#define pb push_back
#define sz(x) int(x.size())
#define all(x)  (x).begin(), (x).end()

const int inf = INT_MAX;
const int maxn = 1e6 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-8;

int n,a[maxn], b[maxn];


int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n;
    for(int i = 0; i < n; i ++)
        cin >> a[i];
    b[n-1] = a[n-1];
    for(int i = n-2; i >= 0; i--)
    {
        b[i] = a[i] -(-1 * a[i+1]);
    }
    for(int i = 0; i < n; i ++)
        cout << b[i] << ' ';
    cout << endl;
}
/*
*/ 


Comments

Submit
0 Comments
More Questions

1512D - Corrupted Array
667B - Coat of Anticubism
284B - Cows and Poker Game
1666D - Deletive Editing
1433D - Districts Connection
2B - The least round way
1324A - Yet Another Tetris Problem
246B - Increase and Decrease
22E - Scheme
1566A - Median Maximization
1278A - Shuffle Hashing
1666F - Fancy Stack
1354A - Alarm Clock
1543B - Customising the Track
1337A - Ichihime and Triangle
1366A - Shovels and Swords
919A - Supermarket
630C - Lucky Numbers
1208B - Uniqueness
1384A - Common Prefixes
371A - K-Periodic Array
1542A - Odd Set
1567B - MEXor Mixup
669A - Little Artem and Presents
691B - s-palindrome
851A - Arpa and a research in Mexican wave
811A - Vladik and Courtesy
1006B - Polycarp's Practice
1422A - Fence
21D - Traveling Graph