1 / 5
Jul 2019

Here is my code in JAVA:

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class AtomsInTheLab {

public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int p = Integer.parseInt(br.readLine());
    while (p > 0) {
        String[] nkm = br.readLine().split(" ");
        long n = Long.parseLong(nkm[0]);
        long k = Long.parseLong(nkm[1]);
        long m = Long.parseLong(nkm[2]);

        System.out.println((int) (Math.log(m * 1.0 / n) / Math.log(k)));
        p--;
    }
}

}

It’s giving me WA at 0.80 sec. I have tried all test cases from my side, its working fine.

for 10 2 3 , it is coming as 0
second input is incorrect as k=1, it should be greater than equal to 2 as per constraints

When I run it on ideone, I get -1.