#abc355e. E - Guess the Sum(Waiting SPJ)

E - Guess the Sum(Waiting SPJ)

Score : 500500 points

问题陈述

这是一个交互式问题(你的程序通过输入和输出与裁判进行交互)。

你给定一个正整数 NN 和整数 LLRR,使得 0LR<2N0 \leq L \leq R < 2^N。裁判有一个隐藏的序列 A=(A0,A1,,A2N1)A = (A_0, A_1, \dots, A_{2^N-1}),由0到99之间的整数组成。

你的目标是找出 AL+AL+1++ARA_L + A_{L+1} + \dots + A_R 除以100的余数。然而,你不能直接知道序列 AA 中元素的值。相反,你可以向裁判提出以下问题:

  • 选择非负整数 iijj,使得 2i(j+1)2N2^i(j+1) \leq 2^N。设 l=2ijl = 2^i jr=2i(j+1)1r = 2^i (j+1) - 1。询问 Al+Al+1++ArA_l + A_{l+1} + \dots + A_r 除以100的余数。

mm 为确定任何序列 AAAL+AL+1++ARA_L + A_{L+1} + \dots + A_R 除以100的余数所需的最少问题数量。你需要在 mm 个问题内找到这个余数。

以上为大语言模型 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 NN and integers LL and RR such that 0LR<2N0 \leq L \leq R < 2^N. The judge has a hidden sequence A=(A0,A1,,A2N1)A = (A_0, A_1, \dots, A_{2^N-1}) consisting of integers between 00 and 9999, inclusive.

Your goal is to find the remainder when AL+AL+1++ARA_L + A_{L+1} + \dots + A_R is divided by 100100. However, you cannot directly know the values of the elements in the sequence AA. Instead, you can ask the judge the following question:

  • Choose non-negative integers ii and jj such that 2i(j+1)2N2^i(j+1) \leq 2^N. Let l=2ijl = 2^i j and r=2i(j+1)1r = 2^i (j+1) - 1. Ask for the remainder when Al+Al+1++ArA_l + A_{l+1} + \dots + A_r is divided by 100100.

Let mm be the minimum number of questions required to determine the remainder when AL+AL+1++ARA_L + A_{L+1} + \dots + A_R is divided by 100100 for any sequence AA. You need to find this remainder within mm questions.

Constraints

  • 1N181 \leq N \leq 18
  • 0LR2N10 \leq L \leq R \leq 2^N - 1
  • 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 NN, LL, and RR from Standard Input:

NN LL RR

Then, repeat asking questions until you can determine the remainder when AL+AL+1++ARA_L + A_{L+1} + \dots + A_R is divided by 100100. Each question should be printed in the following format:

?? ii jj

Here, ii and jj must satisfy the following constraints:

  • ii and jj are non-negative integers.

  • 2i(j+1)2N2^i(j+1) \leq 2^N

The response to the question will be given in the following format from Standard Input:

TT

Here, TT is the answer to the question, which is the remainder when Al+Al+1++ArA_l + A_{l+1} + \dots + A_r is divided by 100100, where l=2ijl = 2^i j and r=2i(j+1)1r = 2^i (j+1) - 1.

If ii and jj do not satisfy the constraints, or if the number of questions exceeds mm, then TT 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 AL+AL+1++ARA_L + A_{L+1} + \dots + A_R is divided by 100100, print the remainder SS in the following format and terminate the program immediately:

!! SS

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 N=3N=3, L=1L=1, R=5R=5, and A=(31,41,59,26,53,58,97,93)A=(31, 41, 59, 26, 53, 58, 97, 93). In this case, m=3m=3, so you can ask up to three questions.

InputOutputDescription
3 1 5First, the integers $N$, $L$, and $R$ are given.
? 0 1Ask 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 1Ask 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 2Ask 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.
! 37The answer is $37$, so print this value.
}