2nd test case not passing

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here

	Scanner scan = new Scanner(System.in);

	int t = scan.nextInt();
	scan.nextLine();

	while( t > 0){

		String[] val = scan.nextLine().split(" ");

		double n = Double.valueOf(val[0]);
		double k = Double.valueOf(val[1]);
	
		double antilog = Math.log(n)/k;
	
		int result = (int) Math.exp(antilog);
	
		System.out.println(result);

		t--;
	}

	

}

}

hey @prashant_potter
Failing for test cases like this :
1
100000000000000 1

So when k =1 simply print n

Hello @aa1,

Its still showing an wrong answer, I tried int, long even i printed string.

Just add the case when k=1 print n

import java.util.*;
public class Main {
public static void main(String args[]) {
// Your Code Here

	Scanner scan = new Scanner(System.in);

	int t = scan.nextInt();
	scan.nextLine();

	while( t > 0){

		String[] val = scan.nextLine().split(" ");

		double n = Double.valueOf(val[0]);
		double k = Double.valueOf(val[1]);

		if(k == 1){
			System.out.println(val[0]);
			
		}else{

			double antilog = Math.log(n)/k;
	
			int result = (int) Math.exp(antilog);
	
			System.out.println(result);
		}

		t--;
	}

	

}

}

@aa1 still showing wrong answer

See this logic

if(k==1)
        {
            System.out.println(n);
            continue;
        }
        ll l=1,r=100000000,mid;
        while(l<r)
        {
            mid=l+r+1>>1;
            bool flag=1;
            ll tmp=1;
            for(int i=1;i<=k;i++)
            {
                tmp*=mid;
                if(tmp>n)
                {
                    flag=0;
                    break;
                }
            }
            if(flag)
                l=mid;
            else
                r=mid-1;
        }
        System.out.println(r);

why we used Binary search here ? :sweat_smile:

Yes we will aplly binary search in this problem. For every possible mid obtained by using binary search we will check of it is the best suitable candidate or not for becoming the Kth root and then we reduce the search space of the binary search according to the mid value. If mid^k is greater than N then we will find the best suitable value from left to mid-1 otherwise we will find much larger value by finding it from mid+1 to right.