Kth root problem

i am getting time limit error in one case and one is wrong and one is right

You are using for loop for 1-sqrt(n) in that you are using power function,power function takes log(n) so your soln becomes sqrt(n)logn. As n is very large it will give TLE.
To solve this problem, you can use binary search, newtons methods, or can directly do it by calculating (1/k)th power of n using inbuilt pow function.

if u r saying it about line 15 then what else can we use in its place

use
a=pow(n,1.00/k);
it solve the problem in 1 line.

its not giving correct output, i have updated theh code please check

It seems that this method will fail, as pow function uses inferior estimation and that results in reasonable error for big numbers.
Use Binary search on the search space from 1 to sqrt(N)+10, and at every mid check pow(mid,k) with n

why to take sqrt(n)+10

sqrt will not be giving exact results, just to be on the safe side add 10.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.