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. Python升级已经安装的第三方库

    Python升级已经安装的第三方库 主要两步操作,查看需要升级库,升级库.如下: pip list # 列出安装的库 pip list --outdated # 列出有更新的库 pip install ...

  2. Ansible 动态获取主机列表

    参考文献: http://www.linuxidc.com/Linux/2016-12/138111.htm 附加 这个 include_vars 变量,可以 动态分别环境或者其他条件- hosts: ...

  3. 使用libcurl进行HTTP GET操作

    Working example how to do a GET request with libcurl and save it to a string variable for future use ...

  4. codeforces C. Team 解题报告

    题目链接:http://codeforces.com/problemset/problem/401/C 题目意思:给出0和1的数目(分别为n和m个),问是否能构造一条同时满足连续两个0不能再一起和连续 ...

  5. org.jetbrains.android.uipreview.RenderingException: Failed to load the LayoutLib: com/android/layoutlib/bridge/Bridge : Unsupported major.minor version 52.0

    在Android Studio使用的时候,突然发现Preview功能不能用了,报了一个错,错误如下 org.jetbrains.android.uipreview.RenderingException ...

  6. UVA-11374(最短路)

    题意: 机场快线有经济线和商业线,现在分别给出经济线和商业线的的路线,现在只能坐一站商业线,其他坐经济线,问从起点到终点的最短用时是多少,还有路线是怎样的; 思路: 预处理出起点到所有站的最短距离和终 ...

  7. python之yield和Generator

    首先我们从一个小程序导入,各定一个list,找出其中的素数,我们会这样写 import math def is_Prims(number): if number == 2: return True / ...

  8. RQNOJ魔法石之恋

    魔法石之恋 (stone.pas/c/cpp) [问题描述] 在<Harry Potter and the Sorcerer's Stone>中,想得到魔法石,必须要通过许许多多的测试和游 ...

  9. asio socket设置 server地址与端口的两种方式

     1. 用解释器的方法, 常用来解析域名, 如 // query("www.163.com","80"), 也可以 query("www.163.co ...

  10. Storm 01之 Storm基本概念及第一个demo

    2.1 Storm基本概念 在运行一个Storm任务之前,需要了解一些概念: Topologies :[tə'pɑ:lədʒɪ]拓扑结构 Streams Spouts:[spaʊt]喷出; 喷射; 滔 ...