//square root using binary search
#include<iostream>
#include<cmath>
using namespace std;
long long int squareroot(long long int n,int k)
{
long long int start=1;
long long int end=n;
long long int ans=-1;
while (start<=end)
{
int mid=(start+end)/2;
if (pow(mid,k)<=n)
{ ans=mid;
start=mid+1;
}
else
{
end=mid-1;
}
}
/*
float inc=0.1;
int precision=3;
for (int i = 0; i < precision; i++)
{
while (ans*ans<n)
{
ans=ans+inc;
}
ans-=inc;
inc=inc/10;
}
*/
return ans;
}
int main(){
long long int n;
int t;
cin>>t;
while (t--)
{
cin>>n;
int k;
cin>>k;
long long int ans=squareroot(n,k);
cout<<ans<<endl;
}
return 0;
}
When i run this code in my vs code it gives 999 for 1 1000 1 but in coding blocks online ide i am getting 1000
Hey
In my Sublime IDE also its giving 1000
Please make sure the code u are running in ur VS CODE IDE is same
i have made new file and copied the code above its giving 999 
try using ( (int)pow(mid,k) )
I don’t suspect any other thing causing that problem
this worked
but my mid was also int and k is also int how it could return any other datatype
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.