問題一覧 > 通常問題

No.3501 Digit Products 2

レベル : / AI推定難易度 : 1500 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / リアクティブ問題 (詳しくはこちら)
タグ : (AC するまで非表示) / 解いたユーザー数 97
作問者 : 2251799813685248 / テスター : Naru820 Nzt3 Solalyth
お気に入りにしたユーザー ProblemId : 13166 / 自分の提出
問題文最終更新日: 2026-04-27 21:22:33
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
CPCTF 2026: PPC (順位表) の他の問題:

Problem Statement

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

The judge holds a hidden positive integer $X$ that has $N$ digits in base $10$.

Find $X$ by asking the following question at most $N$ times.

However, if, after asking at most $N$ questions, you find that $X$ cannot be determined as exactly $1$ possibility no matter how at most $N$ questions are asked, report that instead.

  • Specify $2$ different digits in the base-$10$ representation of $X$ and ask for their product.

Constraints

  • $2 \leq N \leq 51$
  • $X$ is a positive integer that has $N$ digits in base $10$, without leading zeros

Input and Output

First, receive $N$ from standard input in the following format.
$N$

Next, ask at least $0$ and at most $N$ questions in the following format.

  • When asking the judge a question

To ask for the product of the $10^a$'s digit and the $10^b$'s digit, print to standard output in the following format. Here, $a,b$ must have no leading zeros and must satisfy $0 \leq a < b \leq N-1$.

$?\ a\  b$

The judge's response is given from standard input in the following format.

$p$

Here, $p$ is the product of the $10^a$'s digit and the $10^b$'s digit of $X$.

However, if you print output in an invalid format during the interaction, or if the number of questions exceeds $N$, then $p = -1$.

In this case, the judge program has already terminated and your submission has been judged as incorrect, so stop your program immediately. Otherwise, the judge result is undefined.

  • When answering the problem

When you have finished asking questions, print the integer $X$ you deduced in the following format.

$!\ X$

However, if you find that the integer $X$ cannot be determined as exactly $1$ possibility within $N$ questions, print the following.

$!$ $-1$
The judge then determines whether your answer is correct as follows.
  1. If the hidden integer $X$ is one that cannot be determined as exactly $1$ possibility within $N$ questions
  2. Your answer is correct only if you correctly report that it cannot be determined; otherwise it is incorrect. Even if you happen to guess the correct value, your answer is incorrect unless you report that it cannot be determined as exactly $1$ possibility.

  3. If the hidden integer $X$ is one that can be determined as exactly $1$ possibility within $N$ questions
  4. If you report that it cannot be determined, your answer is incorrect. Otherwise, your answer is correct if the value you deduced and printed equals the integer $X$, and incorrect if it differs.

Sample Interaction

This is one example of an interaction for $N=3$, $X=201$. (In the actual interaction, you are given only $N$, and $X$ is not given.)
Input Output Explanation
3 First, you receive the integer $N$ from standard input.
? 0 1 Ask the judge for the product of the 1's digit and the 10's digit.
0 The response is 0.
? 0 2 Ask the judge for the product of the 1's digit and the 100's digit.
2 The response is 2.
! -1 You have concluded that the integer $X$ cannot be determined as exactly $1$ possibility. This conclusion is right, so this is judged as correct.

Notes

  • Each time you print output, add a newline at the end and flush standard input. Otherwise, you may get Time Limit Exceeded.
  • After printing your answer, terminate your program normally immediately.

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