Could You Please go through my code I have applied modified binary search but giving the wrong answer.
#include <bits/stdc++.h>
using namespace std;
int binary_method(unsigned long long int start,unsigned long long int end,unsigned long long int k,unsigned long long int n,unsigned long long int mid)
{
if(start>end)
{
return mid;
}
mid=(start+end)/2;
if(pow(mid,k)<=n)
{
//cout<<"upper:"<<mid<<" "<<k<<endl;
return binary_method(mid+1,end,k,n,mid);
}
else if(pow(mid,k)>n)
{
//cout<<"lower:"<<" "<<mid<<" "<<k<<endl;
return binary_method(start,mid-1,k,n,mid);
}
}
int main()
{
int test;
cin>>test;
while(test–)
{
unsigned long long int n;
unsigned long long int k;
cin>>n>>k;
//n=sqrt(n);
unsigned long long int prev_mid=0;
unsigned long long int x=binary_method(0,n,k,n,prev_mid);
cout<<x<<endl;
}
return 0;
}