解題思路: 牛頓迭代法, https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
點擊打開鏈接
class Solution {public: int mySqrt(int x) { long long r = x; while (r*r > x) r = (r + x/r) / 2; return r; }};
新聞熱點
疑難解答