分析:二分模板题,查找比它的开方小的第一个整数
class Solution {
public:
int mySqrt(int x) {
int l=0,r=x;
while(l<r){
int mid = ((long long)l+r+1)/2;
if((long long)mid*mid<=x)l=mid;
else r=mid-1;
}
return l;
}
};