Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- long long get(int n) {
- cout << "? " << n << "\n";
- fflush(stdout);
- long long x;
- cin >> x;
- return x;
- }
- long long sum(int n) {
- return n * (n + 1LL) / 2;
- }
- int main() {
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- int n;
- cin >> n;
- int l = 0, r = n;
- while (l + 1 < r) {
- int m = l + (r - l) / 2;
- if (get(m) == sum(m))
- l = m;
- else
- r = m;
- }
- int res1 = r;
- int sum23 = sum(n) - get(n) - res1;
- int half23 = sum23 / 2;
- int res2 = sum(half23) - get(half23);
- if (res1 <= half23)
- res2 -= res1;
- int res3 = sum23 - res2;
- cout << "! " << res1 << " " << res2 << " " << res3 << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement