Kth root (challenges binary search), my code is working for almost all numbers but is giving wrong answer for very large numbers (10^15), how to deal with this problem sir

#include
#include
#include<math.h>
using namespace std;
long long int findroot(long long int m,long long int h)
{

long long int s=0;
long long int e=m;
long long int mid;
while(s<=e)
{
mid=(s+e)/2;
long long int g;
g =pow(mid,h);
if(g>m)
{ e=mid-1; }
else if(g==m)
{ return mid;}
else
s=mid+1;
}

return mid-1;
}
int main() {

long long int n;
long long int k;
int t;
cin>>t;
while(t)
{
cin>>n;
cin>>k;
cout<<findroot(n,k)<<endl;
–t;
}
return 0;
}

do not use pow function instead write a for loop for the same and while calculating if the value ever exceeds m return false else true

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.