← All problemsSign in

Minimum Difference

Bob hates different numbers. So whenever he is given two positive integers $A$ and $B$, he reduces the absolute difference between the two numbers to the minimum possible value, i.e., he reduces both the numbers to some value $X$ $(X\leq A)$ and $Y$ $(Y\leq B)$ such that $|X-Y|$ is minimum. To reduce the two numbers, Bob can perform the following operations any number of times (including zero):

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