This C++ solution uses constant-time case analysis for CCC 2026 S1 Baby Hop, Giant Hop. Read the reasoning, inspect the code, or try your own test case below.
ccc26s1CCC 2026 S1MathConstant-time case analysisC++30 lines
Compare the target distance with the giant-hop length K. The quotient and remainder tell us the shortest route; the second-shortest route comes from the closest valid alternative using one extra unit or giant hop.
CCCArithmetic
Time
O(1)
Space
O(1)
Problem and code
Useful links.
Written by benbenyaojifen. Try the problem first, then compare your approach with the code.
Python records executed lines and locals automatically. For selected values in any language, add // @trace i, total on its own valid line; Python uses # @trace i, total.
StatusReady
Output
No run yet.
Diagnostics
No diagnostics yet.
Each run is isolated and has strict limits. Passing one test does not guarantee the judge will accept the solution.