Kth root problem

My code does not clear all test cases. Please explain the mistake in my code.
#include
#include
using namespace std;

int kth_root_search(int n, int k)
{
int s = 0;
int e = n;
int ans = -1;

while(s<=e)
{
	int mid = (s+e)/2;
	if(pow(mid,k)==n)
	{
		return mid;
	}
	else if(pow(mid,k)<n)
	{
		ans = mid;
		s = mid+1;
	}
	else
	{
		e = mid-1;
	}
}
return ans;

}

int main()
{
int t;
cin>>t;
while(t–)
{
int k;
long long int n;
cin>>n>>k;
cout<<kth_root_search(n,k)<<endl;
}
return 0;
}

hello @shreyasdaga
pls share ur code using cb ide.
i will check

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

no not like this.

go to this link -> https://ide.codingblocks.com/
paste ur code in editor
press ctrl +s and save

a link will be generated in ur search bar.
share that link with me.

@shreyasdaga

pls check ur updated code here->

just replaced int with long long to avoid any overflow

It is working now. Thank you.