ATOMS - Atoms in the Lab


Mr. Yagami is a scientist in the Bhabha Atomic Research Centre. They are conducting a lab experiment on nuclear fission. In nuclear fission, one atom breaks into more than one atom of the same type.

Initially, there are N atoms in the lab. Starting from now (t = 0), after each second, every atom will break into K atoms of the same type. They don’t want the number of atoms to exceed M, so they have to stop the reaction at some time t = T. Can you find this value T for Mr. Yagami.

Input

First line contains P, the number of test cases. Next P lines contain three integers each. These three integers represent the values of N, K and M respectively.

Output

For each test case print the time at which the reaction will have to be stopped.

Constraints

1 ≤ P ≤ 10^4
2 ≤ N, K, M ≤ 10^18

Example

Input:
2
2 2 7
2 2 8

Output:
1
2

Explanation

1st test case:

  • at t=1, number of atoms will be 4.
  • at t=2, number of atoms will be 8.

So reaction has to be stopped at t=1.

2nd test case:

  • at t=1, number of atoms will be 4.
  • at t=2, number of atoms will be 8.
  • at t=3, number of atoms will be 16.


Problem Setter: Lalit Kundu


hide comments
mohit_vachhani: 2016-05-23 19:53:42

my 11th,AC in 5 mins. C++

praval_singhal: 2016-05-17 07:41:48

No need of any float or double or log function . simple problem of basic mathematics. AC in one go :)

pranjalikumar9: 2016-05-13 13:04:26

For people who are having trouble optimising with log, try using floor function instead of typecasting. It wont matter if you are using float or double.

vikash1143: 2016-03-09 06:12:52

60 secs in total to write the code for this in python..

street_funker: 2016-02-29 19:37:36

brute force is accepted use float if int is used TLE is shown

dokz: 2016-01-27 12:35:28

Hint: for those who uses Log, check the following test:
1
100000000 5 10

Correct answer: 0

Liquid_Science: 2016-01-17 13:13:08

Something seems wrong in this,was reading no. of test cases through nextInt() and NZEC just at that -_-

Last edit: 2016-01-17 13:13:23
Shashank Tiwari: 2015-12-12 14:50:10

Well, this problem has nothing to do with log() or Big Integer calculation. Though these techniques might give you answer. Careful simplification of ' Inequation to be checked' to avoid overflow . That's it.

Akshay Aradhya: 2015-11-02 19:07:57

After 9 WA got AC. I stopped using log was having a lot of precission problem with it dont know how people even solved it. Just go for the Brute Force method guys, use double to check if the multiplication is going above 10^18

ganpya: 2015-10-28 13:11:02

AC in 5mins exactly. Python :p


Added by:darkshadows
Date:2014-01-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All