Submit | All submissions | Best solutions | Back to list |
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
Added by: | darkshadows |
Date: | 2014-01-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
|
||||||||||||||
2014-09-04 22:27:33 Abhishek K Das
2 2 288230376151711744 ^^ The above number is 2^58 so the answer should be 57 2 2 288230376151711743 Now here the number is 2^58 - 1 so here the answser should 56 . I wrote a program using log which gives 57 for both but it still got accepted. How ? Last edit: 2014-09-05 07:04:29 |
||||||||||||||
2014-08-24 21:22:26 ashish jaiswal
fnally got accepted using log.. Last edit: 2014-08-24 21:40:08 |
||||||||||||||
2014-08-18 11:32:27 shinchan
http://www.spoj.com/files/src/12176295/ getting run time error....help please |
||||||||||||||
2014-07-18 09:10:20 surayans tiwari(http://bit.ly/1EPzcpv)
getting tle at 5th case finally accepted :D after 3 tles Last edit: 2014-07-18 10:05:51 |
||||||||||||||
2014-07-03 16:58:28 Naruto uzumaki
log passed :) |
||||||||||||||
2014-06-27 18:56:09 P_Quantum
easy!! |
||||||||||||||
2014-06-17 21:09:41 tarun018
my solution got accepted using log.... |
||||||||||||||
2014-06-01 05:19:02 ayush
The easiest solution is the right solution ( do not use log() ) |
||||||||||||||
2014-05-27 20:32:12 .:frUstrAteD:.
thanks humble_coder :) |
||||||||||||||
2014-04-18 23:38:09 Gaurav Agrawal
getting wa in 3rd case |