#include #include using namespace std; int main() { int n; int x; cin>>n; for(int i=0;i>x; string nr = bitset<32>(x).to_string(); int right1 = nr.length() - 1; while('1'!=nr[right1]){ right1--; } int count1 = 0; int left0 = 0; while('0'==nr[left0] && left0<32 && count1==0){ if(nr[left0] == '1') count1 = 0; left0++; } while('0'!=nr[left0] && left0<32 && count1==0){ left0++; } if(right1 > left0){ nr[right1] = '0'; nr[left0] = '1'; } cout<(nr).to_ulong()<<" "; } return 0; }