Kth Root question

what is wrong in this code?
I am getting the wrong answer in second test case given

You need to modify your approach little bit as,

long long int s=0,e=n;
long long ans;
long long int x;
long long int mid;

while(s<=e)
{
	 mid=(s+e)/2;
    if(pow(mid,p)==n)
    {
	ans= mid;
    break;
    }
	else 
    if(pow(mid,p)<n)
	{
		ans=mid;
		s=mid+1;
	}
	else
    if(pow(mid,p)>n)
    {
	e=mid-1;
    }
}
cout<<ans;

}

Please explain the problem in my code, because i think my logic is right. Moreover I tried some other testcases having small inputs and answer is coming right.

Your code is working partially… but not covering all testcases… Thts why you can see upon the edited code only… If you didnt understood the changes… You can let me know…