public static boolean judgeSquareSum(int c) {
int a = 0;
int b = (int) (Math.sqrt(c));
while (a <= b) {
int sum = a * a + b * b;
if (sum == c) {
return true;
} else if (sum < c) {
a++;
} else {
b--;
}
}
return false;
}
633. 平方数之和
最新推荐文章于 2024-11-01 15:19:21 发布