显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll m, k, a[110], tot = 0;
void Solve() {
tot = 0;
cin >> m >> k;
for (int i = 5; i >= 0; --i) {
if (k & (1 << i)) {
ll cur = (1 << (1 << i)) - 1;
m -= cur;
a[++tot] = cur;
if (m < 0) {
cout << -1 << '\n';
return;
}
}
}
if (m == 1) {
if (a[tot] != 1) {
cout << -1 << '\n';
return;
}
++a[tot];
} else if (m % 2 == 0) {
a[++tot] = m / 2;
a[++tot] = m / 2;
} else {
a[++tot] = 1;
a[++tot] = 2;
a[++tot] = (m - 3) / 2;
a[++tot] = (m - 3) / 2;
}
cout << tot << '\n';
for (int i = 1; i <= tot; ++i) {
cout << a[i] << ' ';
}
cout << '\n';
}
int main() {
freopen("Sequence.in","r",stdin);
freopen("Sequence.out","w",stdout);
ll T;
cin >> T;
while (T--) {
Solve();
}
return 0;
}