No.3162 Five Two Three
Problem Statement
A sequence of non-negative integers $A$ of length at least $3$ is called a good sequence if $A$ satisfies the following condition.
- $| A_{i-1} - A_{i+1} | = A_i$ holds for $i = 2, 3, \cdots, |A|-1$.
If no good sequence satisfying the conditions exists, output $-1$.
Constraints
- All input values are integers
- $0 \leq X,Y,Z \leq 10^{12}$
Input
$X \ Y \ Z$
Output
Output the shortest good sequence satisfying the conditions of the problem, along with its length $k$, in the following format.
$k$ $A_1 \ A_2 \ \cdots \ A_k$If no good sequence satisfying the conditions exists, output
-1.Print a newline at the end.
Sample
Sample 1
Input
5 3 2
Output
3 5 2 3
Since $|5 - 3| = 2$, this is a good sequence.
It also satisfies the conditions of the problem: it starts with $5$, ends with $3$, and contains $2$ in between.
No good sequence of length shorter than $3$ exists, so this is the only answer.
Sample 2
Input
0 0 1
Output
4 0 1 1 0
It contains multiple $1$ in between, but this is not a problem.
Sample 3
Input
2025 523 2025
Output
-1
The sequence must contain $2025$ at a position other than the first and the last, so, for example, $[2025, 1502, 523]$ does not satisfy the conditions of the problem.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
jastaway
butsurizuki