public static int binarySearch(int x) {
int l = 0, r = x, index = -1;
while (l <= r) {
int mid = l + (r-l)/2;
if ((long)mid * mid <= x) {
index = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
return index;
}
// 牛顿迭代 尚需要了解(时间复杂度更低)