- 248's solution
-
P248's Solution
- @ 2026-4-5 11:28:55
考虑差分,使得 ,。
但此时 导致丢失了一部分信息,于是我们再给 减去 ,此时 。
有了 和 ,我们就可以递推得到 ,至此问题得到解决。
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
cout << 1 << ' ' << 1 << endl;
for (int i = 1; i <= n; i++)
cout << i << ' ';
cout << n + 1 << endl;
for (int i = 1; i <= n - 1; i++)
cout << i + 1 << ' ';
cout << 1 << ' ' << n + 1 << endl;
return 0;
}
/* ATTENTION!!! THIS IS THE BARRIER!!! */
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 12;
long long a[N], b[N];
int main()
{
int n, X0 = 1, Y0 = 1;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> b[i];
a[n] = -b[1];
for (int i = n - 1; i >= 1; i--)
a[i] = a[i + 1] - b[i + 1];
for (int i = 1; i <= n - 1; i++)
cout << a[i] << ' ';
cout << a[n] << endl;
return 0;
}