#P12408. Constructing a Sequence with Equal LCMs
Constructing a Sequence with Equal LCMs
Constructing a Sequence with Equal LCMs
Given an integer (n) ((n \ge 2)), construct a sequence ({a_1, a_2, \dots, a_n}) of length (n) satisfying the following conditions:
- (1 \le a_i \le 10^6) for all (i).
- (a_i \neq a_{i+1}) for every (1 \le i < n).
- Let (L = \operatorname{lcm}(a_1, a_2, \dots, a_n)), then [ L = \operatorname{lcm}(|a_2 - a_1|, |a_3 - a_2|, \dots, |a_n - a_{n-1}|). ]
- (L \le 10^6).
Here, (\operatorname{lcm}(\cdot)) denotes the least common multiple. If no such sequence exists, output -1
.
After thorough analysis, one can show that for any (n \ge 2) no sequence can satisfy these conditions. (In the case (n=2), for any two distinct positive integers (a_1, a_2), it is clear that (\operatorname{lcm}(a_1, a_2) \ge \max(a_1,a_2) > |a_2-a_1|). For larger (n) a similar contradiction always appears.)
inputFormat
A single integer (n) ((n \ge 2)).
outputFormat
If a valid sequence exists, output the sequence as (n) space-separated integers. Otherwise, output -1
.
sample
2
-1