2118.Guess the Array

Time Limit: 1s Memory Limit: 256MB

This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should use fflush(stdout), in Java you should use System.out.flush(), and in Pascal- flush(output).

In this problem you should guess an array a which is unknown for you. The only information you have initially is the length n of the array a.

The only allowed action is to ask the sum of two elements by their indices. Formally, you can print two indices i and j (the indices should be distinct). Then your program should read the response: the single integer equals to ai+aj.

It is easy to prove that it is always possible to guess the array using at most n requests.

Write a program that will guess the array a by making at most n requests.

Input Format(From the terminal/stdin)

Output Format(To the terminal/stdout)

Sample Input

Copy
5 9 7 9 11 6
 · · · ·  · \n

Sample Output

Copy

? 1 5 ? 2 3 ? 4 1 ? 5 2 ? 3 4 ! 4 6 1 5 5
\n
 · · · · · · · · · · · · · · · · · · · · \n

Hints

The format of a test to make a hack is:
The first line contains an integer number n (3 \le n \le 5000)- the length of the array. The second line contains n numbers a1,a2,...,an (1 \le ai \le 105)- the elements of the array to guess.

Submit

请先 登录

© 2025 FAQs