#P7071. [CSP-J 2020] 优秀的拆分
[CSP-J 2020] 优秀的拆分
Description
In general, a positive integer can be decomposed into the sum of several positive integers.
For example, , , and so on. For a specific decomposition of a positive integer , we call it “excellent” if and only if, under this decomposition, is split into several distinct powers of with positive integer exponents. Note that a number can be written as a power of with a positive integer exponent if and only if can be obtained by multiplying together a positive integer number of times.
For example, is an excellent decomposition. However, is not an excellent decomposition, because is not a power of with a positive integer exponent.
Now, given a positive integer , you need to determine whether there exists an excellent decomposition among all decompositions of this number. If it exists, output a specific decomposition scheme.
Input Format
The input contains only one line with an integer , which is the number to be checked.
Output Format
If there exists an excellent decomposition among all decompositions of this number, output each number in the decomposition from large to small, with a single space between adjacent numbers. It can be proven that after fixing the order of the numbers in the decomposition, the scheme is unique.
If no excellent decomposition exists, output -1.
6
4 2
7
-1
126
64 32 16 8 4 2
Hint
Explanation for Sample 1
is an excellent decomposition. Note that is not an excellent decomposition, because the numbers in the decomposition are not all distinct.
Constraints
- For of the testdata, .
- For another of the testdata, is guaranteed to be odd.
- For another of the testdata, is guaranteed to be a power of with a positive integer exponent.
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号