Hotter Colder

아직 제출이 없습니다시간 제한5초메모리 제한256 MB

문제

Jack and Jill play a game called Hotter, Colder. Jill has a number between 1 and N, and Jack makes repeated attempts to guess it.

Each of Jack's guesses is a number between 1 and N. In response to each guess, Jill answers hottercolder or same. For Jack's first guess, Jill answers same. For the remaining guesses Jill answers:

  • hotter if this guess is closer to Jill's number than his previous guess
  • colder if this guess is farther from Jill's number than his previous guess
  • same if this guess is neither closer to nor further from Jill's number than his previous guess.

You are to implement a procedure HC(N) that plays Jack's role. This implementation may repeatedly call Guess(G), with G a number between 1 and N. Guess(G) will return 1 to indicate hotter, -1 to indicate colder or 0 to indicate sameHC(N) must return Jill's number.