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

简单粗暴
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题解之判断是否为平方数之和的更多相关文章
- C#版 - Leetcode 633. 平方数之和 - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...
- [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 ...
- C#刷遍Leetcode面试题系列连载(4) No.633 - 平方数之和
上篇文章中一道数学问题 - 自除数,今天我们接着分析 LeetCode 中的另一道数学题吧~ 今天要给大家分析的面试题是 LeetCode 上第 633 号问题, Leetcode 633 - 平方数 ...
- [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 ...
- Java实现 LeetCode 633 平方数之和(暴力大法)
633. 平方数之和 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 ...
- 【JavaScript】Leetcode每日一题-平方数之和
[JavaScript]Leetcode每日一题-平方数之和 [题目描述] 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c . 示例1: 输入:c = 5 ...
- leetcode.双指针.633平方数之和-Java
1. 具体题目 给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a^2 + b^2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 注 ...
- 力扣(LeetCode)平方数之和 个人题解
给定一个非负整数 c ,你要判断是否存在两个整数 a 和 b,使得 a2 + b2 = c. 示例1: 输入: 5 输出: True 解释: 1 * 1 + 2 * 2 = 5 示例2: 输入: 3 ...
- 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 ...
随机推荐
- UVA732【DFS+栈】
题目:已知两个单词,利用一个栈,将第一个单词变成第二个单词,求出所有可能的操作序列. #include <stdio.h> #include<iostream> #includ ...
- HIve:beeline终端上在输错hive语句时,无论 Backspace还是delete 都删除不掉错误的语句,没有办法退格
通过SecureCRT工具连上linux后,通过beeline连接上hive后,在输错hive语句时,无论 Backspace还是delete 都删除不掉错误的语句,没有办法退格. 解决方案: 第一步 ...
- 新手创建Vue项目
======================安装vue=============================(参考网址:http://www.bubuko.com/infodetail-21320 ...
- ASP.NET CORE系列【六】Entity Framework Core 之数据库迁移
前言 最近打算用.NET Core写一份简单的后台系统,来练练手 然后又用到了Entity Framework Core 发现园子里有些文章讲得不是那么细节,对于新手小白来说,可能会有点懵. 特意整理 ...
- Python数据抓取_BeautifulSoup模块的使用
在数据抓取的过程中,我们往往都需要对数据进行处理 本篇文章我们主要来介绍python的HTML和XML的分析库 BeautifulSoup 的官方文档网站如下 https://www.crummy.c ...
- Linux服务器断电导致挂载及xfs文件损坏的修复方法
系统文件损坏后进入紧急修复模式,无法进行维护工作 welcome to emergency mode!after logging in ,type "journalctl -xb" ...
- ios开发-程序压后台后,悄悄的抓取数据~~
我们使用某个app的时候,当我们将程序压到后台之后,我们希望它还能从服务器抓取一些数据,类似微博,微信,qq这些程序压后台 之后,我们依然能看到icon上显示未读数量.但是ios系统是伪多任务操作系统 ...
- CSS常用字体属性(多出的文本隐藏,或者以省略号的形式显示)和背景样式以及背景图的2个不常用属性:background-origin和background-clip
(一)常用的字体属性: font-weight: 属性值100-900 400等于正常 700等于bold ,数值越大,越粗 font-size:字体大小,单位可以为px或者% font-famil ...
- [COGS 2877]老m凯的疑惑
Description Margatroid退役之后沉迷文化课 这天,写完数学作业之后的他脑洞大开,决定出一道比NOIP2017 D1T1<小凯的疑惑math>还要好的题 题面是这样的 $ ...
- 紧急疏散evacuate
1689: [HNOI2007]紧急疏散evacuate 题目描述 发生了火警,所有人员需要紧急疏散!假设每个房间是一个N M的矩形区域.每个格子如果是".",那么表示这是一块空地 ...