1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <vector>
using namespace std;
const int C=1000001;

int amount_of_bits[C];
vector<int> to_show;
int main(){
	amount_of_bits[0] = 0;
	for (int i=1; i<C; i++) amount_of_bits[i] = amount_of_bits[i/2] + i%2;

	int n, summa=0, i;
	scanf ("%d", &n);
	for (i=1; ; i++){
		summa += amount_of_bits[i];
		if (summa >= n) break;
	}

	for (; i>0; i--){
		if (summa - amount_of_bits[i] >= n) summa -= amount_of_bits[i];
		else to_show.push_back(i);
	}

	printf ("%d\n", to_show.size());
	for (auto x: to_show) printf ("%d ", x);
	printf ("\n");

return 0;}