Sigma c-program

let’s consider a set that will call sigma which consists of an integer sequence with the following properties
a0=1
am=n
a0<a1<a2…<am-1<am
quelque soit k apartient [1,m] il existe i&j apartiennent [0,k-1]such that ak=ai+aj
given an integer n as input your program should construst a,d outputs a sequence of inegers with minimal length satisfying the properties above for n
note thet there can be more than one sequence satisfying the properties your program should output the one with the maximal sum
Input:
the input consists of 100 test cases text cases are stored in an input file named sigma in .eatch test case in the file is stored in a separate line and the number -1 marks the end of the input file
Output:
the output file file should be named sigma out and should follow this organization
each test case output consits of a sequence of integers separated by one blank
Sample Input:

3

4

9

77

80

87

99

-1

Sample Output:

1 2 3

1 2 4

1 2 4 8 9

1 2 4 8 9 17 34 68 77

1 2 4 8 16 32 64 80

1 2 4 8 16 24 28 29 58 87

1 2 4 8 16 32 33 66 99

1 Like

Please write your question in English.

1 Like