class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param c int整型
* @return bool布尔型
*/
bool square(int c) {
// write code here
int a = 1;
int b = (int)sqrt((double)c);
while(a <= b) {
int tmp = a*a + b*b;
if (tmp > c) {
b--;
} else if (tmp < c) {
a++;
} else {
return true;
}
}
return false;
}
};

京公网安备 11010502036488号