Here is the code. Please help with the issue.
#include
#include <math.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
long n,k;
cin>>n>>k;
long min=0;
long max=n;
long mid = max;
while(min != max)
{
if(pow(mid,k) > n){
max = mid-1;
}
else if(pow(mid,k) < n)
{
min = mid+1;
}
else if(k == 1){
mid = max;
break;
}
else if(pow(mid,k) == n)
{
break;
}
mid = (min+max)/2;
}
cout<<mid<<endl;
}
return 0;
}