633. 平方数之和 //因为leetcode上的测试用例的范围非常大,因此一定要使用unsigned int,否则会溢出 class Solution { public: bool judgeSquareSum(int c) { unsigned int l = 0; unsigned int r = sqrt(c); while(l <= r) { unsigned int sum = l*l + r*r; if(sum == c) return true; else if(sum < c) l++; else r--; } return false; } };