CS-Notes
CS-Notes copied to clipboard
发现一点小错误
class Solution {
public:
bool judgeSquareSum(int c) {
if(c<0) return false;
int i=0,j=(int)sqrt(c);
while(i<=j)
{
// long powSum=i*i+j*j;//不建议使用pow 会出现 上溢
// if (powSum==target) return true;
// else if(powSum>target) --j;
// else ++i;
if(c-i*i==j*j) return true;
else if(c-i*i<j*j)--j;
else ++i;
}
return false;
}
};
这样来写的 话 就可以了 会出现 溢出的情况 希望作者更细一下
是的,溢出的问题 +1 建议修改一下
是的,溢出的问题 +1 建议修改一下
害 问题不大
11