改下牛顿迭代,因为还是平方所以问题不大 class Solution { public boolean isPerfectSquare(int num) { double x = num; while (true) { double x1 = (x + num / x) / 2; if (x - x1 < 1e-6) { break; } x = x1; } int ans = (int) x; return ans * ans == num; }} 这么说起来和69差差不多