二分法求根(向下取整)

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