两数平方和
633. Sum of Square Numbers (Easy)
Input: 5
Output: True
Explanation: 1 * 1 + 2 * 2 = 5
题目描述:
判断一个数是否为两个数的平方和。
代码:
public boolean judgeSquareSum(int c){
int i=0;
int j=(int)Math.sqrt(c);
while(i<=j){
int sum=i*i+j*j;
if(sum==c)
return true;
else if(sum<c){
i++;
}else{
j++;
}
}
return false;
}