当mid * mid=x或者mid* mid<x&&(mid+1)*(mid+1)>x,mid就答案

import java.util.*;
public class Solution {
    public int mysqrt (int x) {
        // write code here
        int r,l,mid;
        l=0;r=x;mid=(l+r)/2;
        
        if(x<=1)return x;
        while(l<=r){
            if(mid<=x/mid&&(mid+1)>x/(mid+1))return mid;
            else if(mid>x/mid)r=mid-1;
            else l=mid+1;
            mid = (l+r)/2;
        }
        return 0;
    }
}