二分,为了不使用long long,过程中需要一些技巧
class Solution {
public:
int mySqrt(int x) {
if(x<=1) return x;
int l=0,r=x;
while(l<=r)
{
int m=(l+r)>>1;
if(m>x/m) r=m-1;
else if(m*m==x) return m;
else l=m+1;
}
return l-1;
}
};