#P1118. FJ's Sum Puzzle
FJ's Sum Puzzle
FJ's Sum Puzzle
FJ and his cows are playing an interesting mental game with numbers. Initially, the numbers from to (with ) are arranged in some order. Then, adjacent numbers are repeatedly summed to form a new list until only one number is left. Formally, if the initial sequence is , then the final number is given by:
$$\text{Final} = \sum_{i=1}^{N} \binom{N-1}{i-1} a_i. $$The cows now challenge FJ: given the final number and , determine the original permutation of numbers that produces the given final number. It is guaranteed that a unique solution exists.
inputFormat
The input consists of a single line containing two integers separated by a space: (the number of numbers) and (the final total after the summing process).
outputFormat
Output the unique permutation of numbers from to (separated by spaces) that produces the final sum when the described process is applied.
sample
4 16
3 1 2 4