QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#710500#6394. Turn on the Light_sexyboyTL 0ms0kbC++14444b2024-11-04 20:08:182024-11-04 20:08:19

Judging History

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

  • [2024-11-04 20:08:19]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-04 20:08:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,res,l,r,mid,tmp,tt;
int main(){
    cin>>n;r=n;l=1;mid=(l+r)/2;
    while(r!=l){
        printf("? %d\n",mid);
        scanf("%d",&tt);
        if(tt==tmp){
            printf("! %d\n",mid);return 0;
        }
        else if(tt==tmp+1){
            tmp=tt;l=mid+1;
        }
        else{
            tmp=tt;r=mid-1;
        }
    }
    printf("! %d\n",r);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3

output:


result: