package leetcode;

/**
 * https://leetcode.com/problems/sum-of-square-numbers/
 */
public class Problem633 {
    public boolean judgeSquareSum(int c) {
        for (int i = 1; i <= c / 2; i++) {
            double a = Math.sqrt(i);
            double b = Math.sqrt(c - i);
            if (a == (int) a && b == (int) b) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Problem633 prob = new Problem633();
        System.out.println(prob.judgeSquareSum(5)); // true
        System.out.println(prob.judgeSquareSum(3)); // false
        System.out.println(prob.judgeSquareSum(Integer.MAX_VALUE)); // false
    }
}

@@ -157,78 +157,45 @@
     
-for (int i = 1; i %3C= c / 2; i++) %7B%0A            double a = Math.sqrt(i)
+if (c == 0) %7B%0A            return true
 ;%0A  
@@ -204,21 +204,37 @@
     
+%7D%0A
     
-double b 
+    for (int i = 1; i %3C
 = Ma
@@ -246,14 +246,17 @@
 rt(c
- - i);
+); i++) %7B
 %0A   
@@ -269,39 +269,43 @@
    i
-f (a == (int) a && b == (int) b
+nt a = i * i;%0A            if (a %3E c
 ) %7B%0A
@@ -316,35 +316,29 @@
             
-return true
+break
 ;%0A          
@@ -353,325 +353,147 @@
     
-%7D%0A
     
-    return false
+double b = Math.sqrt(c - a)
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem633 prob = new Problem633();%0A        System.out.println(prob.judgeSquareSum(5)); // true%0A        System.out.println(prob.judgeSquareSum(3)); // false%0A        System.out.println(prob.judgeSquareSum(Integer.MAX_VALUE)); //
+    if (b == (int) b) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return
  false
+;
 %0A   

Solve problem 633