#abc355e. E - Guess the Sum(Waiting SPJ)
E - Guess the Sum(Waiting SPJ)
Score : points
问题陈述
这是一个交互式问题(你的程序通过输入和输出与裁判进行交互)。
你给定一个正整数 和整数 和 ,使得 。裁判有一个隐藏的序列 ,由0到99之间的整数组成。
你的目标是找出 除以100的余数。然而,你不能直接知道序列 中元素的值。相反,你可以向裁判提出以下问题:
- 选择非负整数 和 ,使得 。设 和 。询问 除以100的余数。
设 为确定任何序列 的 除以100的余数所需的最少问题数量。你需要在 个问题内找到这个余数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
This is an interactive problem (where your program interacts with the judge via input and output).
You are given a positive integer and integers and such that . The judge has a hidden sequence consisting of integers between and , inclusive.
Your goal is to find the remainder when is divided by . However, you cannot directly know the values of the elements in the sequence . Instead, you can ask the judge the following question:
- Choose non-negative integers and such that . Let and . Ask for the remainder when is divided by .
Let be the minimum number of questions required to determine the remainder when is divided by for any sequence . You need to find this remainder within questions.
Constraints
- All input values are integers.
Input and Output
This is an interactive problem (where your program interacts with the judge via input and output).
First, read the integers , , and from Standard Input:
Then, repeat asking questions until you can determine the remainder when is divided by . Each question should be printed in the following format:
Here, and must satisfy the following constraints:
-
and are non-negative integers.
-
The response to the question will be given in the following format from Standard Input:
Here, is the answer to the question, which is the remainder when is divided by , where and .
If and do not satisfy the constraints, or if the number of questions exceeds , then will be -1
.
If the judge returns -1
, your program is already considered incorrect. In this case, terminate the program immediately.
Once you have determined the remainder when is divided by , print the remainder in the following format and terminate the program immediately:
Notes
- At the end of each output, print a newline and flush Standard Output. Otherwise, the verdict may be TLE.
- If your output is malformed or your program exits prematurely, the verdict will be indeterminate.
- After printing the answer, terminate the program immediately. Otherwise, the verdict will be indeterminate.
Example
Here is an example for , , , and . In this case, , so you can ask up to three questions.
Input | Output | Description |
---|---|---|
3 1 5 | First, the integers $N$, $L$, and $R$ are given. | |
? 0 1 | Ask the question with $(i, j) = (0, 1)$. | |
41 | $l=1$ and $r=1$, so the response is the remainder when $A_1=41$ is divided by $100$, which is $41$. The judge returns this value. | |
? 1 1 | Ask the question with $(i, j) = (1, 1)$. | |
85 | $l=2$ and $r=3$, so the response is the remainder when $A_2 + A_3 = 85$ is divided by $100$, which is $85$. The judge returns this value. | |
? 1 2 | Ask the question with $(i, j) = (1, 2)$. | |
11 | $l=4$ and $r=5$, so the response is the remainder when $A_4 + A_5 = 111$ is divided by $100$, which is $11$. The judge returns this value. | |
! 37 | The answer is $37$, so print this value. |