← All problemsSign in

Reach the Destination

You are given a starting integer s, and a destination integer t, from the set of m integers {0,1 ,..,m-1}. Now, you are given two integers - x and y. For any integer i in the described set, you are allowed to perform the following two operations: - change i to (i + x) % m - change i to (i - y) % m You need to calculate the minimum number of operations required to convert s to t. Input The

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