Educational Codeforces Round 56 (Rated for Div. 2) CodeForces - 1093C
阿新 • • 發佈:2018-12-17
題意:
有一個序列a ,有n個數
給出一個序列b,且滿足 bi=ai+an−i+1
求序列a,答案不唯一,滿足就行
#include<stdio.h> #include<iostream> #include<algorithm> #include<cmath> #include<cstring> #include<string.h> #include<queue> #include<stack> #include<list> #include<map> #include<set> #include<vector> using namespace std; typedef long long int ll; typedef unsigned long long ull; const int maxn =2e5+5; const int maxm=10000; const int mod =1e9+7; const int INF=0x3f3f3f3f; const double eps=1e-8; int n; ll a[maxn]; ll b[maxn]; int main() { scanf("%d",&n); for(int i=1;i<=n/2;i++) scanf("%lld",&b[i]); a[n+1]=0x7fffffffffffffff; for(int i=1;i<=n/2;i++) { a[i]=a[i-1]; a[n+1-i]=b[i]-a[i]; if(a[n+2-i]<a[n+1-i]) { a[n+1-i]=a[n+2-i]; a[i]=b[i]-a[n+1-i]; } } for(int i=1;i<=n;i++) { printf("%lld ",a[i]); } }