当前位置:网站首页>Leetcode skimming questions_ Sum of squares
Leetcode skimming questions_ Sum of squares
2022-07-06 01:24:00 【Figure throne】
Title Description
Given a nonnegative integer c , You have to decide if there are two integers a and b, bring a2 + b2 = c .

Java resolvent
class Solution {
public boolean judgeSquareSum(int c) {
long a = 0;
int b = (int)Math.sqrt(c);
while(a <= b)
{
// a * a + b * b It is possible to surpass int Value range , Need to use long
if(a * a + b * b > c)
{
b--;
}
else if(a * a + b * b < c)
{
a++;
}
else
{
return true;
}
}
return false;
}
}
C resolvent
bool judgeSquareSum(int c){
long a = 0;
int b = (int)sqrt(c);
while(a <= b)
{
// a * a + b * b It is possible to surpass int Value range , Need to use long
if(a * a + b * b > c)
{
b--;
}
else if(a * a + b * b < c)
{
a++;
}
else
{
return true;
}
}
return false;
}
边栏推荐
- Test de vulnérabilité de téléchargement de fichiers basé sur dvwa
- Five challenges of ads-npu chip architecture design
- ORA-00030
- 【全网最全】 |MySQL EXPLAIN 完全解读
- Vulhub vulnerability recurrence 74_ Wordpress
- MUX VLAN configuration
- Kotlin basics 1
- Construction plan of Zhuhai food physical and chemical testing laboratory
- ADS-NPU芯片架构设计的五大挑战
- Leetcode1961. Check whether the string is an array prefix
猜你喜欢
![[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction](/img/b4/3d46a33fa780e5fb32bbfe5ab26a7f.jpg)
[pat (basic level) practice] - [simple mathematics] 1062 simplest fraction

MATLB | real time opportunity constrained decision making and its application in power system

Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates

Test de vulnérabilité de téléchargement de fichiers basé sur dvwa

电气数据|IEEE118(含风能太阳能)

VMware Tools installation error: unable to automatically install vsock driver

Une image! Pourquoi l'école t'a - t - elle appris à coder, mais pourquoi pas...

Finding the nearest common ancestor of binary tree by recursion

Huawei Hrbrid interface and VLAN division based on IP

【详细】快速实现对象映射的几种方式
随机推荐
Distributed base theory
【SSRF-01】服务器端请求伪造漏洞原理及利用实例
Recoverable fuse characteristic test
网易智企逆势进场,游戏工业化有了新可能
普通人下场全球贸易,新一轮结构性机会浮出水面
About error 2003 (HY000): can't connect to MySQL server on 'localhost' (10061)
FFT learning notes (I think it is detailed)
Code Review关注点
JVM_ 15_ Concepts related to garbage collection
【全網最全】 |MySQL EXPLAIN 完全解讀
Use of crawler manual 02 requests
Superfluid_ HQ hacked analysis
Test de vulnérabilité de téléchargement de fichiers basé sur dvwa
在产业互联网时代,将会凭借大的产业范畴,实现足够多的发展
有谁知道 达梦数据库表的列的数据类型 精度怎么修改呀
Zhuhai's waste gas treatment scheme was exposed
A Cooperative Approach to Particle Swarm Optimization
Netease smart enterprises enter the market against the trend, and there is a new possibility for game industrialization
Kotlin basics 1
GNSS terminology