题意:https://www.luogu.com.cn/problem/CF1630A
思路:可以发现当两个数相加等于n-1时,与起来肯定是0,那么我们考虑调换位置使得为k,当k不等于n-1的时候,我们直接让n-1去与k,然后让0去与本来k与的数。原理很简单就是0与上任何数都是0,然后我们考虑怎么构造n-1,那么我们在构造出n-2的情况下,考虑让他加个1,那么我们让0与上1与上的数即可。
/*keep on going and never give up*/
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define lowbit(x) x&(-x)
#define endl '\n'
#define wk is zqx ta die
pii q[1000005];
signed main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
int n, k;
cin >> n >> k;
if (n == 4 && k == 3) {
cout << "-1" << endl;
continue;
}
for (int i = 0; i < n / 2; i++) {
q[i] = {i, n - 1 - i};
}
if (k != n - 1) {
if (k < n / 2) {
q[k].first = 0;
q[0].first = k;
} else {
int j = n - 1 - k;
q[j].second = 0;
q[0].first = k;
}
} else {
q[1].second = n - 3;
q[0].second = 2;
q[2].first = n - 1;
q[2].second = n - 2;
}
for (int i = 0; i < n / 2; i++) {
cout << q[i].first << " " << q[i].second << endl;
}
}
return 0;
}