My code is getting test cases 0 and 2 correct but showing was a test case 1
Here is my code
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long int n,k;
cin>>n>>k;
long long int ans;
long long int i=1,j=1000000;
while(i<=j)
{
long long int mid=(i+j)/2;
long long int flag=0,value=1;
for(int l=1;l<=k;l++)
{
value=value*mid;
if(value>n)
{
flag=1;
break;
}
}
if(flag)
{
j=mid-1;
}
else
{
if(value==n)
{
ans=mid;break;
}
else
{
ans=mid;
i=mid+1;
}
}
}
cout<<ans<<endl;
}
}