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
#include <bits/stdc++.h>
using namespace std;

int maks_potega_2(int a){
    int i = 0;
    while (a % (1 << (i + 1)) == 0){
        i++;
    }
    return i;
}

int main(){
    int n;
    cin >> n;
    int T[1000001];
    int suma = 0;
    int indeks = 0;
    vector <int> W;
    T[0] = 0;
    while (suma < n){
        indeks++;
        T[indeks] = T[indeks - 1]+ 1 - maks_potega_2(indeks);
        suma += T[indeks];
    }
    int roznica = suma - n;
    while (indeks > 0){
        if (T[indeks] <= roznica){
            roznica -= T[indeks];
        }
        else{
            W.push_back(indeks);
        }
        indeks--;
    }
    printf("%d \n",W.size());
    for (int i= 0; i < W.size();i++){
        printf("%d ",W[i]);
    }
}