class Solution {
public:
int mySqrt(int x) {
int l = 0, r = x;
while (l < r) {
long long mid = (long long )l + r + 1 >> 1; //r可能越界 int mid = l + 1ll + r >> 1;
if (mid == x / mid) return mid;
else if (mid < x / mid) l = mid;
else r = mid - 1;
}
return l;
}
};