题解:P10306 「Cfz Round 2」How to Prove
szh_AK_all · · 题解
分析
既然我们要让
首先考虑让两个元素之和尽可能重复的构造方案。
很显然,我们将元素两两分组,最多会有
那么在这种构造下,多个元素之和重复的数量也是最多的,我们可以将两两分组的元素合并成一个元素,那么合并的这些元素,便都为
Code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++) {
cout << ans << " ";
if (ans == 0 || ans < 0)
ans = -ans + 1;
else
ans = -ans;
}
cout << endl;
}
}