/** * @author chengxy * @date 2018/6/28 9:29 */ public class DemoTest0268 { public static void main(String[] args) { int c = 10000000; boolean b = judgeSquareSum(c); System.out.println(b); } public static boolean judgeSquareSum(int c) { int a = 0; int b = (int) Math.sqrt(c); while (a <= b) { if (a * a + b * b == c) { return true; } else if (a * a + b * b < c) { a++; } else { b--; } } return false; } }
leetCode 平方数之和 java
最新推荐文章于 2023-02-01 15:29:28 发布