#P8568. [JRKSJ R6] func
[JRKSJ R6] func
Description
This is an interactive I/O problem.
You have a linear function (). This linear function satisfies that and are both integers and .
vectorwyx modified this function. Specifically, he chooses an integer (), shifts the part of the function on the line and to its right by unit to the right, and then connects the endpoints of the two parts with a line segment, obtaining a piecewise function :
$$g(x)=\begin{cases} kx+b&1\le x<t\\ kt+b& t\le x <t+1\\ k(x-1)+b& t+1\le x \le n \end{cases}$$Please obtain the value of through interaction.
Interaction
There are multiple test cases in one test point.
- First read an integer from standard input, representing the number of test cases.
- Next, you will interact for test cases. For each test case, first read three integers from standard input.
- You can make a query by outputting
? l r p(, ) to standard output. In one test case, you can perform at most?operations. The interactor will process your query in the following order and send the result to standard input:- If your query range is invalid, the answer is . The interactor will immediately return WA. You must exit your program immediately to avoid TLE caused by interacting with an already terminated interactor.
- If , the answer is .
- Otherwise, the answer is .
- You can output
! tto standard output to give the answer. You can answer only once, and the answer operation must be the last operation you perform in each test case. After the interaction ends, read an integer (0 or 1) from standard input. If , your answer for the current test case is correct, and you should go back to step to proceed to the next test case. Otherwise, if , you must exit your program immediately.
Do not forget to flush the output buffer after each output, otherwise you will get TLE.
Below are some ways to flush the output buffer in different languages:
- C++:
fflush(stdout)orcout.flush(). - C:
fflush(stdout). - Java:
System.out.flush(). - Python:
stdout.flush(). - Pascal:
flush(output). - Other languages: please refer to the documentation of the corresponding language.
Input Format
See “Interaction”.
Output Format
See “Interaction”.
1
5 999 999
0
1
1
? 1 3 2
? 4 5 2
! 3
Hint
Sample Explanation
Note that the sample is only used to show the interaction rules, and it may not be logically meaningful.
Sample #1
(), .
$$g(x)=\begin{cases} 3x-2&1\le x<3\\ 7& 3\le x <4\\ 3x-5& 4\le x \le 5. \end{cases}$$So the result of the first query is , and the result of the second query is .
Constraints
This problem uses bundled judging. Also, there is no restriction that one subtask contains all other subtasks.
| Subtask | Score | Special Property | ||||
|---|---|---|---|---|---|---|
| None | ||||||
| Slope is odd | ||||||
| None | ||||||
For of the data, it is guaranteed that , . Also, $\forall x \in [1,n], 0 \le g(x)\le 7857125847061472735$.
Notes
Since there is no restriction that one subtask contains all other subtasks, the upper bounds of and in the “For of the data” part have no real meaning. However, if we directly wrote “For of the data, , ”, some reviewers might reject it as “Is this what you call constraints?”. Therefore, this meaningless upper bound is kept in this problem statement.
Translated by ChatGPT 5
京公网安备 11011102002149号