CF1968C 题解
思路
首先 只要比 大就行,例如 就一定合法(因为 )。后面的 不仅要满足 ,还要满足 。但 的范围要求很大,足足有 ,所以只要随便构造一个就好。这里我用的是保守的方法,就是用 来得出一个最小的 使得 且 。当然也有二分等许多方法,我这里就不详细说明了。
代码
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
int t, n, a[200005], lst;
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> t;
while (t --) {
cin >> n;
for (int i = 1; i < n; ++ i)
cin >> a[i];
a[n] = 0;
cout << (lst = a[1] + 1);
for (int i = 1; i < n; ++ i) {
lst = (a[i + 1] + lst - a[i]) / lst * lst + a[i];
cout << ' ' << lst;
}
cout << '\n';
}
return 0;
}

浙公网安备 33010602011771号