代码:
class Solution { public: bool isPerfectSquare(int num) { long long a = (long long)num; long long left = 0; long long right = a; while (left <= right) { long long mid = left + ((right - left) >> 1); if ((mid * mid) < a) { left = mid + 1; } else if ((mid * mid) > a) { right = mid -1; } else { return true; } } return false; } };
标签:平方,right,mid,long,num,367,LeetCode,left From: https://www.cnblogs.com/konosekai/p/17397873.html