#Q22. 「一本通 1.3 例 4」Addition Chains
「一本通 1.3 例 4」Addition Chains
Description
Original source: ZOJ 1937
Given a sequence (where , , and ). For each , it must satisfy (, where and can be equal).
Given the value of , find the minimum value of (no need to output it) and the value of each term in such a sequence (there may be multiple valid sequences; output any one that satisfies the conditions).
Input Format
Multiple test cases, each line contains a positive integer .
The input ends with .
Output Format
For each test case, output a sequence of the smallest possible length that satisfies the conditions.
Sample 1
5
7
12
15
77
0
1 2 4 5
1 2 4 6 7
1 2 4 8 12
1 2 4 5 10 15
1 2 4 8 9 17 34 68 77
Constraints & Hints