제출 #986142

#제출 시각아이디문제언어결과실행 시간메모리
986142amirala21Guess the number (BOI20_guess)Cpython 3
0 / 100
10 ms2996 KiB
import math
import sys
def binary_search_guessing_game():
    upperBoundary = int(input("input"))
    sys.stdout.flush()
    lowerBoundary = 1
    finalGuess = None
    for _ in range(50): 
        guess = math.floor((upperBoundary + lowerBoundary) / 2)
        print(f"? {guess}")
        sys.stdout.flush()
        response = int(input())
        if response == 0: 
            finalGuess = guess
            break
        elif response == 1: 
            upperBoundary = guess - 1
        elif response == -1:  
            lowerBoundary = guess + 1
    if finalGuess is not None:
        print(f"= {finalGuess}")
        sys.stdout.flush()
binary_search_guessing_game()
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...