[Huawei OD machine test real questions] Single-plank bridge (C++) 100% pass rate super detailed code comment code interpretation

[Huawei OD machine test real questions 2022&2023] real test catalog @click here @
[Huawei OD machine test real questions] signal transmission and reception & trial reading & @click here @
[Huawei OD machine real test questions] rent a car to ride the greenway & trial reading & @点here@

wooden bridge

topic description

There is a single-plank bridge on the river, and a frog wants to jump from one side of the river to the other along the single-plank bridge. There are some stones on the bridge, and the frog hates to step on these stones. Since the length of the bridge and the jumping distance of the frog are both positive integers, we can regard the possible points of the frog on the single-plank bridge as a series of whole points on the number line: 0, 1, ..., L (where L is the length of the bridge) . The point with coordinate 0 represents the start point of the bridge, and the point with coordinate L represents the end point of the bridge. The frog starts from the starting point of the bridge and keeps jumping towards the end point. The distance of a jump is any positive integer between S and T (including S, T). When the frog jumps to or skips the point whose coordinate is L, it is considered that the frog has jumped out of the single-plank bridge.
subject to

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/130674444