To find kth root

time limit exceeded during compiling can u plz check my code

@ajayrajsingh_817
Consider such testcase
1
1024 10
so in first iteration of binary search your mid will be (0+1024)/2 = 512 , then you are computing pow(mid,k)= pow(512,10) which can’t be computed because it’s ans can’t be stored in any datatype.
We can have much bigger testcase as well. think about it


im not storing it just passing in my complier (dev c++) it works well

sir simple mathmatics use kr ke ho gaya hai bt sir using binary search wo kaise hoga plzz help me out

@ajayrajsingh_817
your binary search is correct but the problem is pow() function.
So take a variable say temp=1 and instead of using pow() function use for loop till i<k. In each iteration multiply temp with mid and check if it’s greater than n or not.

can u plzz share code

@ajayrajsingh_817
I have modified your code. Check the following link

please mark this doubt as resolved if you get the logic.