2025年9月28日 星期日

[633] Sum of Square Numbers

陷入恐慌, 隨抄隨寫

bool judgeSquareSum(int c) {
long long big = floor(sqrt(c));
if (big*big == c)
return true;
int small = 1;
while (small <= big)
{
long long check = small*small + big*big;
if (check ==c)
return true;
else if (check < c)
small++;
else
big--;
}
return false;
}

沒有留言:

張貼留言