Limits 3s, 1.0 GB

Bitcoin is a digital currency created in 2009.It follows the ideas set out in a white paper by the mysterious Satoshi Nakamoto, whose true identity has yet to be verified. Bitcoin offers the promise of lower transaction fees than traditional online payment mechanisms and is operated by a decentralized authority, unlike government-issued currencies.
Bitcoin’s price is increasing day by day. In 2010. 1 Bitcoin was equivalent to 0.003dollar.Now,1Bitcoinisequivalentto0.003 dollar. Now, 1 Bitcoin is equivalent to 18,000. An analyst is predicting that 1 bitcoin will be equal to $25,000 within the next five years. Its value sometimes decreases by some small amount but overall its price is increasing.
Based on this real life scenario, Let us consider that you have currently BequivalentofBitcoin.IneachdaysincetheBitcoinvalueincreases,soyourdollarincreasesbyvalueB equivalent of Bitcoin. In each day since the Bitcoin value increases, so your dollar increases by value P. But, exactly after D days, its value increases by L which is less than P i.e. (L<P). And again this scenario continues infinitely in the same manner. (I.e. exactly at the interval of D+1 day, value increases by L, other days it increases by P). Your task is to predict how many days does it take to reach dollar amount at least X.

Input

Input starts with an integer T(1<=T<=100000) , denoting the number of test cases. Each case starts with 5 integers B, P, D, L, and X.

Constraints:
1<=B,D,X<=10^9
1<=L < P<=10^9

Output

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

Sample

InputOutput
2
2 5 4 3 51
2 5 4 3 46
11
10

Submit

Login to submit.

Statistics

100% Solution Ratio
emrul_muEarliest, Oct '19
Kuddus.6068Fastest, 0.0s
emrul_muLightest, 1.0 MB
emrul_muShortest, 1196B
Toph uses cookies. By continuing you agree to our Cookie Policy.