/** * @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
猜你喜欢
转载自blog.csdn.net/qq_36183706/article/details/80844156
今日推荐
周排行