sqrtx

class Solution {
public:
    int sqrt(int x) {
        int left=1,right=x/2;
        int res;
        if(x<2)return x;
        while(left<=right)
        {
            int mid=(right-left)/2+left;
            if(x/mid>mid)left=mid+1,res=mid;
            else if(x/mid

你可能感兴趣的:(sqrtx)