Given a non-negative integer c, decide whether there’re two integers a and b such that a2 + b2 = c.
1 2 3 4 5 6 7 8 9 10 11 12
classSolution { public: booljudgeSquareSum(int c){ long C = c; for(long a = 0; a * a <= C/2; a++) { if(C - (a * a) == pow((long)sqrt(C - a * a),2)) { returntrue; } } returnfalse; } };