Picu Bank
Tag(s):

## Algorithms, Binary search algorithm, Easy, Mathematics, Searching algorithm

Problem
Editorial
Analytics

You have $D$ dollars with you. You want to put it into a Bank, namely Picu Bank. This bank has a peculiar behavior for interest. Regardless of the Bank deposit amount, every month it adds $A$ dollars to your bank account and this continues till $M$ months. Exaxtly on $M+1$ months, it adds $B$ dollars $(B < A)$ to your bank account. This scanario repeats again in same manner.( i.e on the $(M+2)^{th}$ month $A$ dollars are added, and so on.. ). Your task is to find out how many months does it take for the dollar amount to reach at least $X$, in the bank account .

Input:

Input starts with an integer $T (1 \le T \le 100000)$, denoting the number of test cases.  Each case starts with 5 integers $D, A, M, B$ , and $X$ as described in problem statement.

Constraints:

• $1 \le D,M,X \le 10^9$
• $1 \le B < A \le 10^9$

Output:

For each case of input minimum number of months needed to reach dollar value of at least X in a single line.

Note that the Expected Output feature of Custom Invocation is not supported for this contest.

SAMPLE INPUT
2
2 5 4 3 51
2 5 4 3 46

SAMPLE OUTPUT
11
10

Explanation

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: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

August Circuits '18

OTHER PROBLEMS OF THIS CHALLENGE