算法
(构造)
若 $m < \frac{n^2 + 3n}{2}$,无解。
否则,可构造 $2, 3, \cdots, n, m - \frac{n^2 + n}{2} + 1$,
不能被表示的数为 $m - 1$。
C++ 代码
#include <bits/stdc++.h>
using std::cin;
using std::cout;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
if (m < (n * n + 3 * n) / 2) puts("-1");
else {
for (int i = 2; i <= n; ++i) cout << i << " ";
cout << m - (n * n + n) / 2 + 1 << '\n';
cout << m - 1 << '\n';
}
}
return 0;
}