class Solution {
public: int mySqrt(int x) { if(x<2)return x; int l = 1 ; int r = x/2; while(l<r){ int m = r - (r - l)/2; if(m>x/m) r = m - 1; else l = m; } return l; }};本文共 226 字,大约阅读时间需要 1 分钟。
class Solution {
public: int mySqrt(int x) { if(x<2)return x; int l = 1 ; int r = x/2; while(l<r){ int m = r - (r - l)/2; if(m>x/m) r = m - 1; else l = m; } return l; }};转载于:https://www.cnblogs.com/clover-xuqi/p/7250611.html