Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2)
C
Guess the Array
Codeforces
1400
原题
← BD →
翻译中…

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 $*a*_{*i*} + *a*_{*j*}$.

翻译中…

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.

翻译中…

Interaction

翻译中…

In each test your program should guess a single array.

翻译中…

The input starts with a line containing integer $*n*$ ($3 ≤ *n* ≤ 5000$) — the length of the array. Your program should read it at first.

翻译中…

After that your program should print to the standard output the requests about the sum of two elements or inform that the array is guessed.

翻译中…
  • In case your program is making a request to ask the sum of two elements, it should print line in the format "? i j" ($*i*$ and $*j*$ are distinct integers between $1$ and $*n*$), where $*i*$ and $*j*$ are indices in the array $*a*$.
  • In case your program informs that the array is guessed, it should print line in the format "! a1 a2 ... an" (it is guaranteed that all $*a*_{*i*}$ are positive integers not exceeding $10^{5}$), where $*a*_{*i*}$ is the $*i*$-th element of the array $*a*$.
翻译中…

The response on a request is a single integer equal to $*a*_{*i*} + *a*_{*j*}$, printed on a separate line.

翻译中…

Your program can do at most $*n*$ requests. Note that the final line «! a1 a2 ... an» is not counted as a request.

翻译中…

Do not forget about flush operation after each printed line.

翻译中…

After you program prints the guessed array, it should terminate normally.

翻译中…

Note

翻译中…

The format of a test to make a hack is:

翻译中…
  • The first line contains an integer number $*n*$ ($3 ≤ *n* ≤ 5000$) — the length of the array.
  • The second line contains $*n*$ numbers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{5}$) — the elements of the array to guess.
翻译中…

样例

Input #1
5
 
9
 
7
 
9
 
11
 
6
 
Output #1
 
? 1 5
 
? 2 3
 
? 4 1
 
? 5 2
 
? 3 4
 
! 4 6 1 5 5
InputCopy OutputCopy
题目信息
标签
构造
交互题
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。