#GYM104745D. jbum
jbum
Description
Javier, the natty bodybuilder who bench presses $1073741824$ kg, is training bench press.
In order to reach the desired weight for the lift, Javier will have to use the $duplicator$. If he puts $x$ discs into the $duplicator$, after $1$ minute he will have twice as many. To use the machine again, he has to remove all the discs and put in the desired number again. Since he's loaded up on creatine and pre-workout, this action takes no time at all. Initially, he only has one disc that his friend Bumstead gave him. It's also important to note that the bar he uses for the lift is magical and weighs nothing.
Javier needs $n$ discs to do his exercise. You need to help him determine the minimum number of minutes it will take for him to reach the desired weight. If the minimum number of minutes is $m$, you also need to tell him how many discs he should put into the $duplicator$ in the $i$-th minute, in order to reach the weight in the minimum possible time.
If there are multiple ways to put discs into the $duplicator$ to reach the weight $n$ in $m$ minutes, you should print the lexicographically smallest sequence.
A sequence of numbers $a$ is lexicographically smaller than another sequence $b$ of the same length, if there exists an index $i$ such that $a_i < b_i$ and for all $j$ such that $1 \leq j < i$, it holds that $a_{j} = b_{j}$.
The only line contains an integer $n$ $(2 \leq n \leq 10^9)$, the weight that Javier wants to lift.
The first line of the output should contain an integer $m$, the minimum number of minutes Javier needs to perform his set with the desired weight.
The second line should contain $m$ integers, $x_1, x_2, \ldots, x_m$, where $x_i$ is the number of discs that Javier puts into the $duplicator$ in the $i$-th time. Remember that if there are multiple possible ways to reach the weight in $m$ minutes, you should print the sequence that is lexicographically smallest.
Input
The only line contains an integer $n$ $(2 \leq n \leq 10^9)$, the weight that Javier wants to lift.
Output
The first line of the output should contain an integer $m$, the minimum number of minutes Javier needs to perform his set with the desired weight.
The second line should contain $m$ integers, $x_1, x_2, \ldots, x_m$, where $x_i$ is the number of discs that Javier puts into the $duplicator$ in the $i$-th time. Remember that if there are multiple possible ways to reach the weight in $m$ minutes, you should print the sequence that is lexicographically smallest.
1024
33
10
1 2 4 8 16 32 64 128 256 512
6
1 1 2 4 8 16
Note
—
Problem idea: Hectorungo18
Problem preparation: Hectorungo18
Ocurrences: Novice 4