QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404710#6394. Turn on the Lighthanmx#WA 0ms3568kbC++17669b2024-05-04 15:05:052024-05-04 15:05:05

Judging History

你现在查看的是最新测评结果

  • [2024-05-04 15:05:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3568kb
  • [2024-05-04 15:05:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll ask(ll d)
{
    cout<<"? "<<d<<endl;
    ll n;
    cin>>n;
    return n;
}
void solve()
{
    int n;
    cin>>n;
    ll l=1,r=1e9;
    ll t=0;
    while(l<=r)
    {
        ll mid=(l+r)>>1;
        ll d=ask(mid);
        if(d==t)
        {
            cout<<"!"<<" "<<mid<<endl;
            return;
        }else  if(d>t)
        {
            l=mid+1;
        }else{
            r=mid-1;
        }
        t=d;
        //cout<<l<<" "<<r<<" "<<t<<"\n";
    }
}
int main(){
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3568kb

input:

3

output:

? 500000000

result:

wrong answer Integer parameter [name=x] equals to 500000000, violates the range [1, 3]