Would you my check approach

would you please check if my approach is correct or not if it is then why i am not getting answer

here is my code

#include
#include<math.h>
using namespace std;
#define ll long long int
ll KTHRoot(ll n,ll k){
ll s=0,e=n;
ll mid;
while(s<=e){
ll mid=(s+e)/2;
ll result=pow(mid,k);
if(mid<=n){
s=mid+1;
}
else{
e=mid-1;
}
}
return mid;
}
int main() {
int t;
cin>>t;
while(t>0){
ll n,k;
cin>>n>>k;
cout<<KTHRoot(n,k)<<endl;

    t--;
}
return 0;

}

i have done some modification see it

#include
#include<math.h>
using namespace std;
#define ll long long int
ll KTHRoot(ll n,ll k){
ll s=0,e=n;
ll mid,ans;
while(s<=e){
ll mid=(s+e)/2;
ll result=pow(mid,k);
if(result==n)return mid;
if(mid<n){
s=mid+1;
ans=mid;
}
else{
e=mid-1;
}
}
return ans;
}
int main() {
int t;
cin>>t;
while(t>0){
ll n,k;
cin>>n>>k;
cout<<KTHRoot(n,k)<<endl;

t--;

}
return 0;

}

if it is giving wrong ans then use newton’s method
read about it.
according to newton’s method
x(K+1) = x(K) – f(x) / f’(x)
here f(x) = x^(N) – A
so f’(x) = N*x^(N - 1)
and x(K) denoted the value of x at Kth iteration
putting the values and simplifying we get,
x(K + 1) = (1 / N) * ((N - 1) * x(K) + A / x(K) ^ (N - 1))

any other method instead of newton’s method?

no it’s not working it giving different value

you can find pow(n,float(1)/k)
it will also give correct ans

i tried pow(n,1.0/k) but it doesn’t work

it will work
float t=(float)1/k;
int ans=pow(n,t);
cout<<ans;
done it in this way
because pow() will give ans in float and we have to print in int