問題一覧 > 通常問題

No.3246 80% Accuracy Calculator

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 28
作問者 : 👑 AngrySadEight / テスター : 👑 hamamu ygussany
お気に入りにしたユーザー ProblemId : 12471 / 自分の提出
問題文最終更新日: 2026-07-15 09:28:04
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
yukicoder contest 479 AngrySadEightお誕生日コンテスト2025 (順位表) の他の問題:

Problem Statement

This is an interactive problem (a problem in which your program and the judge program interact through standard input and output).


Let's simulate performing calculations on a calculator that succeeds only $8$ times out of ten.

There are $3$ variables $A, B, C$. Initially, variables $A, B$ are initialized with positive integers $x, y$ respectively, prepared in advance by the judge system, and $C$ is initialized with $0$.

Here, $1 \leq x \leq 888, 1 \leq y \leq 888$ holds.

You can perform either of the following operations, Operation 1 or Operation 2, on these variables.

  • Operation 1 : Choose $1$ of the variables $A, B, C$ and query the judge system for its value.
    • When the true value of the queried variable is $z$, the judge system returns $z$ with probability $80\%$, and with probability $20\%$ returns an integer $w$ chosen by the judge satisfying $1 \leq w \leq 8,888,888, \ w \neq z$ (the choice of $w$ is not necessarily random).
  • Operation 2 : Add variables. Choose $3$ variables $v_1, v_2, v_3$, $1$ each from $A, B, C$ (repetition allowed), and have the judge system assign the sum of the value of variable $v_1$ and the value of variable $v_2$ (hereafter called $s$) to variable $v_3$.
    • However, $v_1 \neq v_3, v_2 \neq v_3$ must be satisfied. Also, the value of $s$ must not exceed $8,888,888$ at the time of the operation.
    • The judge system replaces the value of variable $v_3$ with $s$ with probability $80\%$, and with probability $20\%$ replaces the value of variable $v_3$ with an integer $w$ chosen by the judge satisfying $1 \leq w \leq 8,888,888, \ w \neq s$ (the choice of $w$ is not necessarily random).
    • The values of variables $v_1$ and $v_2$ are not rewritten and remain as they are.

Your goal is to reach a state in which one of the variables $A, B, C$ stores the value of $x \times y$.

Achieve the goal within $8888$ operations.

The values of $x, y$ are determined before the interaction starts.

Constraints

  • $1 \leq x, y \leq 888$
  • $x, y$ are integers

Input and Output

This is an interactive problem (a problem in which your program and the judge program interact through standard input and output).

To perform Operation 1, output in the following format. Here, $v$ is the name of the variable whose value you want to query, represented by one of A, B, C.

? $v$

The response to this query is given from standard input in the following format.

$z$

Here, $z$ is the response to the query returned by the judge system (see above for details).

If you make an invalid query, or if the total number of operations exceeds $8888$, $z = -1$ is given. In this case, your submission has already been judged as incorrect, so terminate your program immediately.

To perform Operation 2, output in the following format. Here, $v_1, v_2, v_3$ are the names of the variables used in the addition, each represented by one of A, B, C. They must be chosen so that $v_1 \neq v_3, v_2 \neq v_3$ is satisfied.

+ $v_1$ $v_2$ $v_3$

The response to this query is given from standard input in the following format.

$z$

Here, if Operation 2 was performed properly, $z=0$ is given. (Note that no information is given on whether the value of $v_3$ was rewritten to $s$.)

If you make an invalid query, or if the total number of operations exceeds $8888$, $z = -1$ is given. In this case, your submission has already been judged as incorrect, so terminate your program immediately.

Once one of the variables $A, B, C$ stores the value of $x \times y$, report it in the following format, then terminate your program. Here, $v$ is the name of the variable storing $x \times y$, represented by one of A, B, C.

! $v$

Your answer is correct if the value of the specified variable is $x \times y$, and incorrect otherwise.

Notes

  • Be sure to flush standard output after every output. Otherwise, you may get TLE.
  • If invalid output is made, the judge result is undefined.
  • If your program does not terminate immediately after $z=-1$ is given as input, the judge result is undefined.
  • After reporting the variable storing $x \times y$, terminate your program immediately. Otherwise, the judge result is undefined.
  • The output reporting the variable storing $x \times y$ is not counted toward the number of queries.
If you are not familiar with reactive problems, please also see the summary of reactive-format problems.

Sample

The following is an example of a correct interaction for the case $x = 2, y = 4$.

Note that although the "Explanation" column below is based on the actual values of the variables, you cannot directly check these values in practice.

InputOutputExplanation
? A Asks for the value of variable $A$.
2 The judge system returned $2$. (The judge system returning the value of the asked variable like this happens with probability $80\%$.)
? B Asks for the value of variable $B$.
3123142 The judge system returned $3123142$. (The judge system returning something other than the value of the asked variable like this happens with probability $20\%$.)
+ A B C Requests the operation of assigning the sum of the values of variables $A, B$ to variable $C$.
0 Operation 2 was performed properly, so $0$ was returned, but the value actually assigned was $1128089$ instead of $2 + 4 = 6$. This makes $(A, B, C) = (2, 4, 1128089)$. (Being rewritten to an integer different from the sum of the $2$ variables like this happens with probability $20\%$.)
+ B B C Requests the operation of assigning the sum of the values of variables $B, B$ to variable $C$. Note that $v_1=v_2$ is allowed.
0 Operation 2 was performed properly, so $0$ was returned, and $4 + 4 = 8$ was actually assigned. This makes $(A, B, C) = (2, 4, 8)$. (Being rewritten to the sum of the $2$ variables like this happens with probability $80\%$.)
! C Reports that the value of variable $C$ is $x \times y = 2 \times 4 = 8$. Since $C = 8$ actually holds, this is correct. Terminate your program here.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。