Nearest Gas Station
CodeChefOpen on judge ↗
Harry is going to his college by his car on an infinite long straight highway. At some point $X$ he ran out of fuel. But on the highway on which he was riding there are many gas stations. Gas stations are available at points $1, 2, 4, 7, 11, 16, 22…..$ $upto$ $infinite$. Now you have to tell how far is the nearest gas station from his current position i.e from point $X$. $Note:-$ You have to
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.
Sign in to chat with the tutor and save your progress.
Sign in to start