← All problemsSign in

No Story

You are given with three integers $x$, $y$ and $target$. You are allowed to perform the following two operations in any random order. **Operation 1:** $x_m = x + y$ $y_m = x - y$ $x = x_m$ $y = y_m$ $k = gcd(x, y)$ **Operation 2:** $k = k + 1$ Initial value of $k$ is greatest common divisor([gcd](https://en.wikipedia.org/wiki/Greatest_common_divisor)) of $x$ and $y$. The cost of

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