問題一覧 > 通常問題

No.3162 Five Two Three

レベル : / AI推定難易度 : 2500 / 実行時間制限 : 1ケース 1.523秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 9
作問者 : 👑 kencho / テスター : fluorine 👑 みうね jastaway tatesoto TKTYI kmmtkm butsurizuki
お気に入りにしたユーザー ProblemId : 12238 / 自分の提出
問題文最終更新日: 2025-05-23 19:01:12
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
KCPC新歓杯 -Happy Birthday physics0523- (順位表) の他の問題:

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$.
You are given non-negative integers $X, Y, Z$. Among the good sequences whose first element is $X$, whose last element is $Y$, and which contain $Z$ as an intermediate element (an element other than the first and the last), construct $1$ shortest one.
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もしくは右上の雲マークをクリックしてアカウントを作成してください。