633. Sum of Square Numbers
来源:互联网 发布:ls算法 编辑:程序博客网 时间:2024/06/05 17:30
题目:
Given a non-negative integer c
, your task is to decide whether there're two integers a
and b
such that a2 + b2 = c.
Example 1:
Input: 5Output: TrueExplanation: 1 * 1 + 2 * 2 = 5
Example 2:
Input: 3Output: False思路:
本题思路是真的简单,只需要循环遍历0-sqrt(c)的整数,判断是否存在符合要求的两个整数。
代码:
class Solution {public: bool judgeSquareSum(int c) { for(int a=0;a<=sqrt(c);a++) { if(sqrt(c-a*a)-int(sqrt(c-a*a))==0.0) return true; } return false; }};
阅读全文
0 0
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers
- 633. Sum of Square Numbers。
- Sum of Square Numbers
- [leetcode]633. Sum of Square Numbers
- [LeetCode]633. Sum of Square Numbers
- LeetCode 633. Sum of Square Numbers
- [leetcode]633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- 633. Sum of Square Numbers标题
- LeetCode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- leetcode 633. Sum of Square Numbers
- [LeetCode]633. Sum of Square Numbers
- 633. Sum of Square Numbers (数学)
- android Arrays.fill()的使用
- 【物联网安全】目前物联网安全相关的应对方案
- css属性选择器,[],=, ~=, ^=, ~=, $=, |=等符号含义
- 脚本语言与编译型语言
- ceph 内核挂载 客户端fue挂载
- 633. Sum of Square Numbers
- Struts2 使用token拦截器控制(防止)重复,刷新,后退 提交数据
- (二) 创建登录页面
- 苹果邀请开发者、媒体前往库伯提诺总部展示 ARKit 应用 ...
- LBP纹理特征提取
- 高级爬虫工程师职位要求
- Unix网络编程代码下载安装及编译
- Vivado调用UEStudio
- 火狐中event事件报错 event is not defined