class Solution { public: /** * * @param x int整型 * @return int整型 */ int mysqrt(int x) { // write code here int left = 0, right = 46342; while(left < right) { int mid = (left + right) / 2; long long y = mid * mid; if(y < x) left = mid + 1; else right = mid; } long long y = left * left; if(y <= x) return left; else return left - 1; } };