class Solution {
public boolean judgeSquareSum(int c) {
long a = 0, b = (long)Math.sqrt(c);
while(a <= b){
long temp = a*a + b*b;
if(temp > c) b--;
else if(temp < c) a++;
else return true;
}
return false;
}
}