Editorial for Và...


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

void solve() {
    int x;
    cin >> x;

    int n = 1;
    while ((1<<n)-2 <= x) ++n;
    --n;

    cout << n << endl;
    for(int i = 0; i < n; ++i) {
        cout << (1<<n)-1-(1<<i) << " ";
    }
    cout << endl;
}

int main() {
    int t; cin >> t;
    while (t--) solve();

    return 0;
}

Comments

Please read the guidelines before commenting.


There are no comments at the moment.