P18094 [CCPC 2026 Changchun] Average

Background

This problem is an **interactive problem**. Please make sure to flush the standard output buffer after every output. The ways to flush in various programming languages are as follows: - For C/C++, use `fflush(stdout)` or `cout.flush()`; - For Java, use `System.out.flush()`; - For Python, use `sys.stdout.flush()`.

Description

Given three pairwise distinct non-negative integers $a,b,c$, Little L defines a series of sets $S_0,S_1,S_2,\dots$ as follows: - Let $S_0=\{a,b,c\}$. For $i\ge 1$, let $S_i=\left\{x\in \mathbb{Z}~\middle|~ \exists\,u,v\in S_{i-1},\ x=\frac{u+v}{2}\right\}$. Answer $q$ queries: - Given a non-negative integer $t$, find the smallest non-negative integer $k$ such that $t\in S_k$. If the answer exists, you also need to construct, in reverse order through $k$ rounds, a way from $t$ back into the set $S_0$. ## Interaction Your program first needs to read one line with three non-negative integers $a,b,c$ ($0\le a

Input Format

N/A

Output Format

N/A

Explanation/Hint

## Sample Consider $S_0=\{0,1,7\}$. Then we can obtain $S_1=S_0\cup \{4\}=\{0,1,4,7\},S_2=S_1\cup \{2\}, S_3=S_2\cup \{3\},S_4=S_3\cup \{5\},S_5= S_4\cup \{6\}=S_6=\dots$. Below, `>` and ` 0 1 7 > 4 ``` The first query is $t=1$, and here $k=0$: ```text > 1 < 0 ``` The second query is $t=2$, and here $k=2$. The following is one possible interaction process: ```text > 2 < 2 < 0 4 > 4 < 1 7 ``` In the $1$-st round, the program takes $0,4\in S_1$ such that $t=2=\frac{0+4}{2}$, and the interactor chooses to change the value of $t$ to $4$; then the program takes $1,7\in S_0$ such that $t=\frac{1+7}{2}$. The third query is $t=5$, and here $k=4$. The following is one possible interaction process: ```text > 5 < 4 < 3 7 > 3 < 2 4 > 4 < 1 7 > 1 < 1 1 ``` Note that even if $t\in S_0$ at the end of the $3$-rd round of interaction, your program still needs to perform the $4$-th round of interaction before it can handle the next query. The fourth query is $t=8$. Since $8\notin S_i$ for every non-negative integer $i$, no valid $k$ exists: ```text > 8 < -1 ``` After all queries are handled, the program terminates. Translated by QwenWork