class Solution { public: /** * * @param x int整型 * @return int整型 / int mysqrt(int x) { if(x <= 0){ return x; } long left = 1; long right = x; while(left <right){ long middle = (left + right )/2; if(middlemiddle <=x && (middle+1)(middle+1) > x){ return middle; }else if(middlemiddle < x){ left = middle; }else{ right = middle; } } return left; // write code here } };