#P11785. Powers of Two Sum Sequence

    ID: 13881 Type: Default 1000ms 256MiB

Powers of Two Sum Sequence

Powers of Two Sum Sequence

Given an integer \(m\), construct a sequence \(a_1, a_2, \dots, a_k\) with the following properties:

  • Each element \(a_i\) is a non-negative integer power of 2, i.e., \(a_i = 2^{p}\) for some integer \(p \ge 0\).
  • The sum of the sequence is \(m\), i.e., \(a_1 + a_2 + \cdots + a_k = m\).
  • The length \(k\) is as small as possible.
  • Among all sequences with the minimal length, the sequence is lexicographically smallest. (A sequence \(x\) is lexicographically smaller than a sequence \(y\) if at the first position where they differ, \(x\) has a smaller element than \(y\).)

It can be proven that a solution always exists for the given constraints.

inputFormat

The input consists of a single integer \(m\) on one line.

outputFormat

Output the lexicographically smallest sequence (with minimal length) of powers of 2 that sum up to \(m\). Print the sequence on one line with the numbers separated by a single space.

sample

1
1