class Solution {
public int mySqrt(int x) {
//利用二分法解决平方根
if(x==1) return 1;
int min=0;
int max=x;
while(max-min>1){
int m=(max+min)/2;
if(x/m<m){
max=m;
}else{
min=m;
}
}
return min;
}
}