题解:P14959 「KWOI R1」Ring Problem
Wyh_dailyAC · · 题解
思路
我的构造比较猎奇。
具体的,我的构造针对
可以易证,当
而又可得一个构造的值为
对于
具体见代码。
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
ll T; cin >> T;
while (T--) {
ll n; cin >> n;
if (n == 1) {
cout << "1\n";
continue;
}
if (n == 2) {
cout << "1 2\n";
continue;
}
if (n == 3) {
cout << "1 2 3\n";
continue;
}
ll m = n - 3;
vector<ll> b;
ll L = 1, R = m;
while (L <= R) {
b.emplace_back(L++);
if (L <= R) b.emplace_back(R--);
}
for (auto &x : b) cout << x << " ";
cout << (n - 1) << " " << n << " " << (n - 2) << "\n";
}
}