Advertisement
fahad005

h.cpp

Jun 20th, 2021
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define pb push_back
  7. #define mx 100010
  8. #define mod 1000000007
  9. #define inf INT_MAX
  10. #define pi acos(-1)
  11. #define endl '\n'
  12. #define fin freopen("input", "r", stdin)
  13. #define Fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  14. //
  15. int main() {
  16.     ll n;
  17.     cin >> n;
  18.     ll ar[n];
  19.  
  20.     ll x, y, z;
  21.     cout << "? 1 2" << endl;
  22.     cout.flush();
  23.     cin >> x;
  24.     cout << "? 2 3" << endl;
  25.     cout.flush();
  26.     cin >> y;
  27.     cout << "? 1 3" << endl;
  28.     cout.flush();
  29.     cin >> z;
  30.  
  31.     ar[0] = (x + z - y) / 2;
  32.     ar[1] = x - ar[0];
  33.     ar[2] = z - ar[0];
  34.  
  35.     for (ll i = 4; i <= n; i++) {
  36.         cout << "? " << 1 << " " << i << endl;
  37.         cout.flush();
  38.         cin >> x;
  39.         ar[i - 1] = x - ar[0];
  40.     }
  41.    
  42.     cout << "! ";
  43.     cout.flush();
  44.     for (ll i = 0; i < n; i++) {
  45.         cout << ar[i] << " ";
  46.         cout.flush();
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement