This problem is a harder version of Permutations & Products. In this version, you can only ask questions where
Larry the magical panda is bored of eating bamboo cookies, so he challenges you to a game. He has a permutation of
- You will give Larry two distinct indices
and such that is prime - Larry will respond with the result of
Larry allows you to ask at most
Constraints
Interaction
This is an interactive problem, where you and the judge exchange information back-and-forth to solve the problem.
At first, you should read in a line containing the integer
You will then start the interaction by proceeding with your questions. Each question should be formatted as ? i j
followed by a \n
character, with
If you believe you have the solution, you may output !
followed by a space-separated list of
If at any point you attempt an invalid question (such as an invalid output format or a prohibited pair of indices), or you exceed the limit of
Please note that you may need to flush stdout
after each operation, or interaction may halt. In C++, this can be done with fflush(stdout)
or cout << flush
(depending on whether you use printf
or cout
). In Java, this can be done with System.out.flush()
. In Python, you can use sys.stdout.flush()
.
Sample Interaction
>>>
denotes your output. Do not print this out.
5
>>> ? 3 5
10
>>> ? 1 4
4
>>> ? 4 2
3
>>> ! 4 3 2 1 5
Comments