简单粗暴

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题解之判断是否为平方数之和的更多相关文章

  1. C#版 - Leetcode 633. 平方数之和 - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

  2. [LeetCode] Sum of Square Numbers 平方数之和

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...

  3. C#刷遍Leetcode面试题系列连载(4) No.633 - 平方数之和

    上篇文章中一道数学问题 - 自除数,今天我们接着分析 LeetCode 中的另一道数学题吧~ 今天要给大家分析的面试题是 LeetCode 上第 633 号问题, Leetcode 633 - 平方数 ...

  4. [LeetCode] 633. Sum of Square Numbers 平方数之和

    Given a non-negative integer c, your task is to decide whether there're two integers a and b such th ...

  5. Java实现 LeetCode 633 平方数之和(暴力大法)

    633. 平方数之和 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 ...

  6. 【JavaScript】Leetcode每日一题-平方数之和

    [JavaScript]Leetcode每日一题-平方数之和 [题目描述] 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c . 示例1: 输入:c = 5 ...

  7. leetcode.双指针.633平方数之和-Java

    1. 具体题目 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a^2 + b^2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 注 ...

  8. 力扣(LeetCode)平方数之和 个人题解

    给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 示例2: 输入: 3 ...

  9. LeetCode 633. Sum of Square Numbers平方数之和 (C++)

    题目: Given a non-negative integer c, your task is to decide whether there're two integers a and b suc ...

随机推荐

  1. 【WebGL入门】画一个旋转的cube

    最近搜罗了各种资料,发现WebGL中文网特别好用,很适合新手入门:http://www.hewebgl.com/article/getarticle/50 只需要下载好需要的所有包,然后用notepa ...

  2. 初学Java Web(4)——Servlet学习总结

    经过一段时间的学习,对于Servlet有了新的不一样的见解,在这里做一下总结,将近来学习到的知识总结一下. Servlet 的请求流程 浏览器发出请求:http://localhost:80/xxx1 ...

  3. uestc 1703一道更简单的字符串题目

    https://vjudge.net/problem/UESTC-1703 题意:略 思路: 枚举+字符串hash. ans从1到len开始枚举字符串的长度,然后就依次比较各段长度为ans的字符串的h ...

  4. Tensorflow会话Session

    转载自: http://blog.csdn.net/Hanging_Gardens/article/details/72784392 https://www.cnblogs.com/hypnus-ly ...

  5. supervisor安装使用和我踩过的坑

    什么是supervisor: supervisor是一款用python编写的进程管理工具,主要运行于linux系统,不支持windows系统,目前还不能运行于python3下. step1:安装sup ...

  6. Opencv在mac系统的安装与试用

    1.在mac终端内,使用brew安装opencv3,这时我的opencv被安装到/usr/local/Cellar/opencv3/3.2.0内. 2.新建xcode 项目,选择command lin ...

  7. [LeetCode] Maximum Average Subarray I 子数组的最大平均值

    Given an array consisting of n integers, find the contiguous subarray of given length k that has the ...

  8. 多线程利器---队列(queue)

    列表是不安全的数据结构 import threading,time li=[1,2,3,4,5] def pri(): while li: a=li[-1] print(a) time.sleep(1 ...

  9. 手写简单的jq雪花飘落

    闲来无事,准备写个雪花飘落的效果,没有写太牛逼的特效,极大的简化了代码量,这样容易读取代码,用起来也很简单,对于那些小白简直是福利啊,简单易读易学.先直接上代码吧,然后再一一讲解,直接复制粘贴就可以拿 ...

  10. HtmlUnit入门一

    htmlunit 是一款开源的java 页面分析工具,读取页面后,可以有效的使用htmlunit分析页面上的内容. 项目可以模拟浏览器运行,被誉为java浏览器的开源实现.是一个没有界面的浏览器. 采 ...