It is failing some test cases. Please help out.
#include
#include <math.h>
#define ll long long unsigned
using namespace std;
ll power(ll x, ll k)
{
if(k==0){
return 1;
}
ll ans = 1;
while(k–)
{
ans = x*ans;
}
return ans;
}
bool isAns(ll n, ll k, ll mid)
{
if(power(n,k) <= mid)
{
return true;
}
else{
return false;
}
}
int main() {
int t;
cin>>t;
//cout<<power(10,10)<<endl;
while(t--)
{
ll n,k;
cin>>n>>k;
ll s=0;
ll e=n;
ll ans = 1;
while(s<=e)
{
//cout<<"S: "<<s<<" E: "<<e<<endl;
ll mid = (s+e)/2;
//cout<<"Mid: "<<mid<<endl;
if(isAns(mid,k,n))
{
ans = mid;
//cout<<"Ans: "<<ans<<endl;
s = mid+1;
}
else{
e = mid-1;
}
}
cout<<ans<<endl;
}
return 0;
}