# Guessing Game With Optimal Profit

One day, you decide to play a game with your friend out of sheer boredom. Your friend picks out an integer randomly from the range $$[1,1023]$$ and you try to guess it.

You can guess an infinite number of times. Let $$n$$ denote the integer your friend chose and let $$k_i$$ denote the integer you chose on the $$i^\text{th}$$ try. If $$n > k_i$$ your friend will tell you "higher", if $$n < k_i$$ your friend will tell you "lower" and if $$n = k_i$$ then you win the game.

But then, your friend decides this is too boring. He decides to give you 1023 dollars. Every time you make a guess, right or wrong you have to give him $$x$$ dollars, even if you already gave him back the original 1023 dollars or even if you already have negative profits. Since your friend knows that you will play optimally, he sets $$x$$ such that your expected profit after playing the game is 0. Find $$\lfloor x \rfloor$$.

Notation: $$\lfloor \cdot \rfloor$$ denotes the floor function.

×