标签:https pac mat bre algo vector int link over
https://codeforces.com/group/5yyKg9gx7m/contest/270203/problem/H
分析:
#include <stdio.h> #include <cstring> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <iostream> using namespace std; int main() { int n; cin>>n; int b[n+6]; int a[n+6]; bool used[n+6]; for(int i=1;i<=n-1;i++) { cin>>b[i]; } bool over=1; for(int i=1;i<=b[1];i++) { memset(used,0,sizeof used); a[1]=i; used[i]=true; over=1; for(int j=1;j<=n-1;j++) { int p=b[j]-a[j]; if(used[p]||p<=0||p>n) { over=0; break; } used[p]=1; a[j+1]=p; } if(over) break; } for(int i=1;i<=n;i++) { printf("%d ",a[i]); } return 0; }
标签:https pac mat bre algo vector int link over
原文地址:https://www.cnblogs.com/studyshare777/p/12404954.html