1.1 Hill Climb
(RankList for this Question)
Score: 30pts
Time Limit: 2.00 sec
A man is driving a car on a sunny afternoon along a slope. There is too much traffic on the road. In one step, the car moves forward n distance, and consequently in the next step, it moves backward m distance, and so on. There is a manhole on the road x distance away from the starting point. How many steps are required before going past the manhole for the first time?

Constraints
1 ≤ x ≤ 10^5
1 ≤ m < n ≤ 5000

Input Format
Input consists of a single line containing x, n, m denoting distance of the manhole from start point, forward movement and backward movement respectively.

Output Format
For each test case, output a single line containing the total number of steps.

Example 1
Input:
120 7 4

Output:
77

Explanation:
Net distance in each forward and backward step combined (n-m): 7 - 4 = 3.
After taking 38 forward and 38 backwards steps the man is 114 distance away from where he started. Now, when he takes a forward step of 7 he reaches the distance 121, at which point he has crossed the manhole.
Calculation: (3 * 38 = 114) + 7 = 121 => Total steps: 77

Log In to solve the Question