Submission #294567

#TimeUsernameProblemLanguageResultExecution timeMemory
294567linear00000Guess the number (BOI20_guess)C++14
100 / 100
1 ms384 KiB
#include<stdio.h> main() {int N,s,e,m,a;scanf("%d",&N);s=1,e=N; while(s<=e){ m=(s+e)/2; printf("? %d\n",m); fflush(stdout); scanf("%d",&a); if(a<0)s=m+1; else if(a>0)e=m-1; else break; } printf("= %d\n", m); return 0; }

Compilation message (stderr)

Guess.cpp:2:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    2 | main() {int N,s,e,m,a;scanf("%d",&N);s=1,e=N;
      |      ^
Guess.cpp: In function 'int main()':
Guess.cpp:2:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    2 | main() {int N,s,e,m,a;scanf("%d",&N);s=1,e=N;
      |                       ~~~~~^~~~~~~~~
Guess.cpp:7:6: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    7 | scanf("%d",&a);
      | ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...