class Solution {
public:
int mySqrt(int x) {
double pre = 0, res = 1;
while(abs(pre - res) > 1e-6){
pre = res;
res = res /2 + x/(2*res);
}
return int(res);
}
};
class Solution {
public:
int mySqrt(int x) {
double pre = 0, res = 1;
while(abs(pre - res) > 1e-6){
pre = res;
res = res /2 + x/(2*res);
}
return int(res);
}
};