Kth root,how to handle pow function out of range cases

#include
#include
#include
using namespace std;
int main() {
int t;
cin>>t;
for(int i=0;i<t;i++){
long long int k,n;
cin>>n>>k;
long long int s=0;
long long int e=n;
long long int mid =(s+e)/2;
long long int res=0;
// cout<<n<<k<<endl;
while(s<=e){
mid=(s+e)/2;
long long int cp=pow(mid,k);
if(cp==n){
res=mid;
break;
}
if(cp<n){
res=mid;
s=mid+1;
}
else{
e=mid-1;
}

        }
        cout<<res<<endl;

}

}

hey @yuvrajhcs, use pow function directly in if case instead storing it in another number.I have made changes to your code. You can check them here https://ide.codingblocks.com/s/105842

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.