Jumping Frogs
Practice
5 (1 votes)
Easy
Problem
29% Success 572 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Problem Statement

This is a classic problem we all know. Once upon a time a frog unfortunately jumps into a well of height 'h'. It tries to come out of the well. Frog covers 'p' feet up but slips 'q' feet down due to wetness on the wall in it's every jump.

You will be provided with the required inputs. Output the number of jumps that the frog requires to come out of the well.

Input:
Input consists of three space separated integers h, p, q denoting height of the well, feet that frog covers in one jump and feet slipped by the frog in every jump.

Output:
Print the number of jumps required by the frog to come out of the well.
If it never reaches out of the well print -1.


Constraints:
1≤ h ≤ 10^9
0≤ p,q ≤ 10^9

Sample Input1:
24 5 2
Sample Output1:
8

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
2 votes
Tags:
inverse-moduloEasymath
Points:20
2 votes
Tags:
Modular arithmeticSimple-mathEasy
Points:20
1 votes
Tags:
Data StructuresBrute ForceMathModulus ArithmeticC++Number Theory
Editorial

No editorial available for this problem.