QOJ.ac

QOJ

Type: Editorial

Status: Open

Posted by: bilibili_com

Posted at: 2026-03-09 21:28:30

Last updated: 2026-03-09 21:31:32

Back to Problem

何意味

数轴上有一个袋鼠,你只知道袋鼠的位置 $k$ 满足 $1\le l\le k\le r\le 10^9$,你可以询问一个点 $x$($1 \le x\le 10^9$),交互库返回袋鼠的位置和你询问的点的距离。在 $5$ 次询问内得出袋鼠的位置。

这题是何意味?首先袋鼠不会在 $1$ 的左侧,所以直接询问 $1$,得出的结果就是袋鼠与 $1$ 的距离,然后把这个距离加 $1$ 就是袋鼠的位置。

#include<bits/stdc++.h>
using namespace std;
int main(){
    int T;
    cin>>T;
    while(T--){
        int l,r;
        cin>>l>>r;
        cout<<"? 1"<<endl;
        int x;
        cin>>x;
        cout<<"! "<<x+1<<endl;
    }
}

Comments

No comments yet.