The Lap Where the Backmarker Falls Behind
Time limit2sMemory limit512 MB
Given lap times X (fast) and Y (slow), find the leader's lap number when the leader first laps the slowest driver.
- Level
Easy3 of 10
- Topics
- Math, Simulation
- Solved
- No attempts yet
Problem
In motor racing the leader often catches the last driver and passes him a full lap ahead. From that moment the last driver is one lap behind the leader.
You are given , the time the fastest driver needs to complete one lap, and , the time the slowest driver needs to complete one lap. Determine the number of the leader's lap in which the leader passes the slowest driver and puts him one lap behind.
Both drivers start side by side on the start line and begin lap 1 at the same instant, and each one runs at a constant speed. A new lap of the leader begins every time the leader crosses the start line. If the pass happens exactly at the instant the leader crosses the start line, the answer is the number of the lap that was being run up to that instant.
Input
The first line contains two integers and separated by a space (). is the time the fastest driver needs for one lap and is the time the slowest driver needs for one lap, both in seconds.
Output
Print on one line the number of the leader's lap at which the slowest driver becomes one lap behind.