如果构造一个递增序列,如 1 , 2 , 3 , 4 , . . . 1,2,3,4,... 1,2,3,4,... ,可以发现是存在一定规律的,一一列举。
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
ll x;
cin >> x;
vector<int> ans;
int cnt = 1;
ll res = 2;
while(res <= x) {
ans.push_back(cnt ++);
res *= 2;
}
///cout << res << endl;
res /= 2;
ll d = x - res;
for(int i = 60; i >= 0; i --) {
if((d >> i) & 1) ans.push_back(i + 1);
}
cout << ans.size() << "\n";
for(auto j: ans) cout << j << ' ';
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T --) {
solve();
}
}