This is an interactive problem. You should use flush operation after each printed line. For example, in C++ you should usefflush(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 bedistinct). 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.

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 "! aa2 ... an" (it is guaranteed that all ai are positive integers not exceeding 105), where ai is the i-th element of the array a.

The response on a request is a single integer equal to ai + aj, printed on a separate line.

Your program can do at most n requests. Note that the final line «! aa2 ... 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.

Example
input
5
 
9
 
7
 
9
 
11
 
6
 
output
 
? 1 5
 
? 2 3
 
? 4 1
 
? 5 2
 
? 3 4
 
! 4 6 1 5 5
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 a1, a2, ..., an (1 ≤ ai ≤ 105) — the elements of the array to guess.

题意:给出未知的两个数和ai,大概给n次要你求出整个数组,还得脑补出这些数字和是哪两个数字加的

解法:

1 我们构造前三个数字b1 b2 b3(稍微计算一下),然后第4个数字开始就是拿a4-b1、、a5-b1。。。

2 额,这输入老是有问题。。。不过思路一定是对的

 fflush(stdout);
scanf("%d",&n);
printf("\n");
fflush(stdout);
printf("? 1 2\n\n");
scanf("%d",&a[]); fflush(stdout);
printf("? 1 3\n\n");
scanf("%d",&a[]); fflush(stdout);
printf("? 2 3\n\n");
scanf("%d",&a[]); fflush(stdout);
b[]=(a[]+a[]-a[])/;
b[]=(a[]+a[]-a[])/;
b[]=a[]-b[];
for(int i=;i<=n;i++){
fflush(stdout);
printf("? 1 %d\n\n",i);
scanf("%d",&a[i]);
b[i]=a[i]-b[]; }
printf("\n! ");
for(int i=;i<=n-;i++){
printf("%d ",b[i]);
}
printf("%d\n",b[n]);
return ;

Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) C的更多相关文章

  1. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) D

    The organizers of a programming contest have decided to present t-shirts to participants. There are ...

  2. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) B

    Vasily exited from a store and now he wants to recheck the total price of all purchases in his bill. ...

  3. Technocup 2017 - Elimination Round 1 (Unofficially Open for Everyone, Rated for Div. 2) A

    Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types ...

  4. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) C

    Description Santa Claus has Robot which lives on the infinite grid and can move along its lines. He ...

  5. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) B

    Description Santa Claus decided to disassemble his keyboard to clean it. After he returned all the k ...

  6. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) A

    Description Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the f ...

  7. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

  8. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. Codeforces Round #380 (Div. 1, Rated, Based on Technocup 2017 - Elimination Round 2)

    http://codeforces.com/contest/737 A: 题目大意: 有n辆车,每辆车有一个价钱ci和油箱容量vi.在x轴上,起点为0,终点为s,中途有k个加油站,坐标分别是pi,到每 ...

随机推荐

  1. /dev/sda2 is mounted; will not make a filesystem here!

    一定要记住,不可以在分区挂载之后再进行格式化!!在错误提示当中可以看出你的分区已经挂载了.先将这个分区卸载了再重新格式化:umount /dev/sda2mkfs.ext2 /dev/sda2这样就没 ...

  2. Hihocoder #1095 : HIHO Drinking Game (微软苏州校招笔试)( *【二分搜索最优解】)

    #1095 : HIHO Drinking Game 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi and Little Ho are playin ...

  3. AutoItLibrary安装和常见问题解决

    http://blog.csdn.net/bible_reader/article/details/52044345

  4. Java生成UUID不重复的id值

    在Java中创建UUID在网上查资料才知道在Java中,变成了UUID.创建方式也出奇简单System.out.println( java.util.UUID.randomUUID());

  5. Linux删除乱码非空目录

    # ls -li 总用量 drwxr-xr-x root root 2月 : 2.1 -rw-rw-r-- binwen binwen 2月 : Htc_常用软件.zip drwxr-xr-x roo ...

  6. JavaScript Objects in Detail

    JavaScript’s core—most often used and most fundamental—data type is the Object data type. JavaScript ...

  7. cygwin Could not create directory '/home/Administrator/.ssh'

    在cygwin下运行: ssh-keygen -C "634772208@qq.com" -t rsa 时,出现如下错误: cygwin Could not create dire ...

  8. excel 基本用法

  9. SNE降维与可视化

    from sklearn import datasets digits = datasets.load_digits(n_class=5) X = digits.data y = digits.tar ...

  10. 小程序wx:key中的关键字*this

    “保留关键字 *this 代表在 for 循环中的 item 本身,这种表示需要 item 本身是一个唯一的字符串或者数字,如果是对象则不可以 data:{ array:[1,2,3,4,5], ob ...