one of my test case failing please correct me where is problem in my code
KTH ROOT problem
import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
if(t>=1 && t<=10) {
for(int i =0;i<t;i++)
{
long n ,k;
n =sc.nextLong();
k = sc.nextLong();
// consider this case
if(k==1){
System.out.println(n);
continue;
}
if(n>=1 && n<=Math.pow(10,15) && k>=1 && k<=Math.pow(10,4)) {
rootKth(n,k);
}
}
}
}
public static void rootKth(long n1, long k1) {
long max=0;
int exit =0;
for(int x=1;x<10000000;x*=2)
{
if(Math.pow(x,k1)<=n1) {
max = x;
}else {
exit = x;
break;
}
}
for(int i =exit;i>=(exit/2);i--) {
if(Math.pow(i,k1)<=n1) {
max = i;
break;
}
}
System.out.println(max);
}
}
1
2069821909 1
Its Correct output is: 2069821909
And Your Code’s output is: 0