제출 #254762

#제출 시각아이디문제언어결과실행 시간메모리
254762model_codeGuess the number (BOI20_guess)C++14
100 / 100
1 ms288 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N; scanf("%d", &N); int L = 1; int R = N; while (L < R) { int mid = (L + R) / 2; printf("? %d\n", mid); fflush(stdout); int fb; scanf("%d", &fb); if (fb == 0) { L = R = mid; break; } else if (fb < 0) { L = mid + 1; } else { R = mid - 1; } } printf("= %d\n", L); }

컴파일 시 표준 에러 (stderr) 메시지

Guess.cpp: In function 'int main()':
Guess.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &N);
     ~~~~~^~~~~~~~~~
Guess.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &fb);
         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...