Implement int sqrt(int x)
.
Compute and return the square root of x.
好精妙的方法啊
int mySqrt(int x) {
long r = x;
while (r*r > x)
r = (r + x/r) / 2;
return r;
}
Implement int sqrt(int x)
.
Compute and return the square root of x.
好精妙的方法啊
int mySqrt(int x) {
long r = x;
while (r*r > x)
r = (r + x/r) / 2;
return r;
}