← All problemsSign in

From Rational to Binary

CodeChefRating 1845Open on judge ↗

Chef and Divyam are playing a game. They start with a rational number $X$, such that $0 < X < 1$. In each turn, Chef chooses a positive real number $Y$. Then Divyam either adds or subtracts $Y$ to $X$. So $X$ is replaced with either $X+Y$ or $X-Y$. If this number becomes $0$ or $1$, then Chef wins. Otherwise, the game continues. You are given $X$, and you have to determine whether Chef can win i

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start