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 ...
随机推荐
- SpringBoot使用log4j
1.添加log4j相关依赖 在pom.xml文件中添加相关依赖: <!--配置log4j--> <dependency> <groupId>org.springfr ...
- 彻底理解了call()方法,apply()方法和bind()方法
javascript中的每一个作用域中都有一个this对象,它代表的是调用函数的对象.在全局作用域中,this代表的是全局对象(在web浏览器中指的是window).如果包含this的函数是一个对象的 ...
- python JavaScript
JavaScript 一. JavaScript Javascript 在开发中绝大多数情况是基于对象的.也是面向对象的. a. JavaScript的引入方式 1 2 3 4 5 6 7 #直接编写 ...
- Java-Maven(五):Eclipse&Maven下创建java工程&web工程
本章文章主要学习集成了maven插件的eclipse下,创建java project和web project的步骤. 创建java工程 第一步:使用使用maven project来创建java pr ...
- Chrome浏览器vue-devtools插件安装教程
1.打开https://github.com/vuejs/vue-devtools,cmd方式直接输入:git Clone https://github.com/vuejs/vue-devtools. ...
- Django REST framework+Vue 打造生鲜超市(六)
七.用户登录与手机注册 7.1.drf的token (1)INSTALL_APP中添加 INSTALLED_APPS = ( ... 'rest_framework.authtoken' ) toke ...
- [LeetCode] Count Different Palindromic Subsequences 计数不同的回文子序列的个数
Given a string S, find the number of different non-empty palindromic subsequences in S, and return t ...
- OpenShift实战(六):OpenShift日志监控EFK
1.镜像下载 为了防止安装过程中由于镜像下载缓慢导致自动部署失败,所以首先提前下载好EFK镜像. docker pull openshift/origin-logging-fluentd docker ...
- Docker入门之--基础知识
1.先是在Mac上安装. 按照这两个就可以很简单的完成 https://docs.docker.com/docker-for-mac/ https://docs.docker.com/docker-f ...
- [BZOJ 4589]Hard Nim
Description 题库链接 两人玩 \(nim\) 游戏,\(n\) 堆石子,每堆石子初始数量是不超过 \(m\) 的质数,那么后手必胜的方案有多少种.对 \(10^9+7\) 取模. \(1\ ...