# 633 Sum of Square Numbers
###### tags: `leetcode`
## Problem Statement
Given a non-negative integer c, decide whether there're two integers a and b such that $a^2 + b^2 = c$
- Example 1:
> Input: c = 5
Output: true
Explanation: 1 * 1 + 2 * 2 = 5
- Example 2:
> Input: c = 3
Output: false
- Example 3:
> Input: c = 4
Output: true
- Example 4:
> Input: c = 2
Output: true
- Example 5:
> Input: c = 1
Output: true
- Constraints:
> $0 \leq c \leq 2^{31} - 1$
## Solution
- Since there are 2 numbers to be summed up, split the answer to be the even 2 portions and track the possible solution.
- Focus on one of the number, the other is ```target- number^2```
```cpp=
int mid= sqrt(c/ 2);
for (int i= mid; i> -1; i--)
{
if (is_square(c- i* i))
return true;
}
```
- To see whether the number is square, compare the square root and the true number.
```cpp=
bool is_square(int target)
{
int mid= sqrt(target);
return mid* mid== target;
}
```