class Solution {
public:
bool judgeSquareSum(int c) {
bool res = false;
for (long long i = 0, j = sqrt(c); i <= j; i ++ )
{
while (i * i + j * j > c) j -- ;
if (i * i + j * j == c)
{
res = true;
return res;
}
}
return res;
}
};