← All problemsSign in

Equate XY

CodeChefRating 1853Open on judge ↗

You have with you four positive integers $X, Y, Z,$ and $C$. You'd like to make $X$ equal to $Y$. To achieve that, you can perform the following types of operations: - Pay one coin, and either increase or decrease $Z$ by $1$. The decrease operation can only be done if $Z \gt 1$ initially, i.e. it's not allowed to make $Z$ reach $0$. - Pay $C$ coins, and do one of the following: - Replace $

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