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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <cstdio>
#include <vector>

using namespace std;

unsigned int cnt(unsigned int n)
{
const unsigned int bm1 = 1431655765,bm2 = 858993459, bm4 = 252645135, bm8 = 16711935, bm16 = 65535;
unsigned int r1,r2,r4,r8,r16;
   
   r1 = (n & bm1) + ((n >> 1)           & bm1);
   r2 = (r1 & bm2) + ((r1 >> 2)         & bm2);
   r4 = (r2 & bm4) + ((r2 >> 4)         & bm4);
   r8 = (r4 & bm8) + ((r4 >> 8)         & bm8);
   r16 = (r8 & bm16) + ((r8 >> 16)      & bm16);
   
   return r16;
}

int main()
{
unsigned int n,i,t;
vector<unsigned int> R;

   scanf("%u",&n);
   t = 0;
   i = 1;
   while (t < n)
   {
	  t += cnt(i); 
	  i++;
   }
   i--;
   while (i > 0)
   {
	  if (t - cnt(i) == n)
	  {
					t -= cnt(i);
	  } else R.push_back(i);
	  i--;
   }

   printf("%u\n",R.size());
   for (vector<unsigned int>::iterator it = R.begin(); it != R.end(); ++it)
				  printf("%u ",*it);
   printf("\n");
   
   return 0;
}