#P7567. Magic Power Assignment
Magic Power Assignment
Magic Power Assignment
The enchanted queen’s gems have been stolen by the Dark God of Gunala and hidden in one of the n domes of the Magic Castle (numbered from 1 to n). Each dome i can be assigned an integer magic power ai. A configuration is said to allow an easy search for the Dark God if the following two conditions hold:
\(\sum_{i=1}^{n} a_i = 0\) and \(\prod_{i=1}^{n} a_i = n\).
Your task is to assign magic powers to the n domes so that the above conditions hold. It is known that a solution exists for some values of n (for example, n = 4 and n = 8). For other values, output -1 to indicate that no assignment is possible.
Note: In all configurations every ai must be a nonzero integer.
inputFormat
The input consists of a single integer n (1 ≤ n ≤ 109).
outputFormat
If there exists an assignment of nonzero integers a1, a2, ..., an satisfying \(\sum_{i=1}^{n} a_i = 0\) and \(\prod_{i=1}^{n} a_i = n\), output the n numbers separated by spaces on one line. Otherwise, output -1.
sample
4
1 -1 2 -2