Little Shino And Equation
Tag(s):

Easy-Medium, Math

Problem
Editorial
Analytics

Little Shino is an intelligent but lazy cat. She measured that the distance between her and her food is $d$ units. She can perform only two operations:

• She can jump $a$ units or $b$ units in the direction of the food.
• She can jump $a$ units or $b$ units in the direction directly opposite to the food.

Since she is lazy, she wants to perform the minimum number of operations required to reach the food. But she is not smart enough to find the solution. Can you find it?

Input Format:
Input contains three space separated integers, $a$, $b$ and $d$ $(1 \le a, b, d \le 10^9)$.

Output Format:
Print the minimum number of operations Little Shino needs to perform to reach the food. Print $-1$ if she can never reach to the food.

SAMPLE INPUT
2 3 10

SAMPLE OUTPUT
4

Explanation

$a = 2$
$b = 3$
$d = 10$
Little Shino can make two jumps of $2$ units towards the food and two jumps of $3$ units towards the food. So she will perform $4$ operations.

She can also make one jump of $2$ units away from the food and then four jumps of $3$ units towards the food. In this case, she will perform $5$ operations, which is not the minimum.

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...