this code is not giving correct output. even it is showing some compile time errors for some cases . please tell what is wrong in the code ?
Kth root problem
hello @Raghavsingla522

a) use long long ,in place of int to avoid overflow.
b) mid^k this will compute xor of mid and k .
to compute mid power k ,either use pow function.
pow(mid,k) or loop.
i would suggest to use loop to avoid overflow
@aman212yadav The program is giving correct output after making suggested changes but when i submitted it, it is shown that program is too slow and we have to come up with a better approach than brute force. but i solved this by binary search . what should i do now to optimize my code ?

use long long here.
handle case where k=1 separately .
dont use pow function .
compute mid^k using loop .
and break the loop if at any point mid^i >=n and perform appropriate updation
i have tried using loop but now it is giving some error and how to handle case where k=1 separately . i am not getting this .
check i have modified it ->
handle k==1 using if statement
shrinked the search space to avoid overflow
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.