We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
应该把变量i, j, powSum的类型改为long,否则会出现整数溢出,2147483600这个测试用例过不了。 修改后如下:
public boolean judgeSquareSum(int target) { if (target < 0) return false; long i = 0, j = (long) Math.sqrt(target); while (i <= j) { long powSum = i * i + j * j; if (powSum == target) { return true; } else if (powSum > target) { j--; } else { i++; } } return false; }
The text was updated successfully, but these errors were encountered:
同!,得改成long
Sorry, something went wrong.
No branches or pull requests
应该把变量i, j, powSum的类型改为long,否则会出现整数溢出,2147483600这个测试用例过不了。
修改后如下:
The text was updated successfully, but these errors were encountered: