Sum of Square Numbers

2019-05-25 22:59:14 浏览数 (1)

1. Description

2. Solution

代码语言:javascript复制
class Solution {
public:
    bool judgeSquareSum(int c) {
        int root = int(sqrt(c))   1;
        for(int i = 0; i < root; i  ) {
            int difference = c - i * i;
            int j = int(sqrt(difference));
            if(i * i   j * j == c) {
                return true;
            }
        }
        return false;
    }
};

0 人点赞