首页 > 其他 > 详细

LintCode题解之判断是否为平方数之和

时间:2017-11-26 10:42:34      阅读:332      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

 

简单粗暴

public class Solution {
    
    /*
     * @param : the given number
     * @return: whether whether there‘re two integers
     */
    public boolean checkSumOfSquareNumbers(int n) {
        int max = (int)Math.sqrt(n) + 1;
        for(int i=0; i<max; i++){
            for(int j=0; j<max; j++){
                if(i*i + j*j == n) return true;
            }
        }
        return false;
    }
    
};

 

题目来源: http://www.lintcode.com/zh-cn/problem/check-sum-of-square-numbers/

LintCode题解之判断是否为平方数之和

原文:http://www.cnblogs.com/cc11001100/p/7898182.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!