367. 有效的完全平方数

给定一个正整数 num,编写一个函数,如果 num 是一个完全平方数,则返回 True,否则返回 False。

说明:不要使用任何内置的库函数,如 sqrt。

示例 1:

输入:16

输出:True

示例 2:

输入:14

输出:False

PS:

牛顿迭代法

class Solution {
public boolean isPerfectSquare(int num) {
if (num < 2) return true;
long x = num;
while (x * x > num) {
x = (x + num / x) / 2;
if (x * x == num) {
return true;
}
}
return false;
}
}

最新文章

  1. [spring源码学习]十、IOC源码-conversionService
  2. C和指针 第九章 习题
  3. 在centos6.7用yum安装redis解决办法
  4. Oracle优化总结
  5. jQuery知识点总结(第四天)
  6. POJ3764 The xor-longest Path(Trie树)
  7. Using QEMU for Embedded Systems Development
  8. MySQL之查询优化方式(笔记)
  9. 调用android方法,出现版本太低解决方法
  10. JSON取值(key是中文或者数字)方式详解
  11. gitlab服务器搭建教程
  12. IntelliJ IDEA编辑器光标定位错误的问题!
  13. ASP.NET Web API相关
  14. 导入到eclipse里的工程挺大的,然后就一直报: An internal error occurred during: &quot;Building workspace&quot;. GC overhead limit exceeded 这个错误。
  15. mysql8.0发布新特性
  16. PHP文件上传与下载
  17. No.02——第一次使用Android Studio,并创建出Hello World
  18. python salt 实现windows账户自动化
  19. 锐捷 rg-S2026f 学习笔记
  20. 实例-PHP_SELF、 SCRIPT_NAME、 REQUEST_URI区别-获取前台公用文-dirname-PHP的&quot;魔术常量&quot;-str_replace

热门文章

  1. u-boot 移植(一)编译环境搭建
  2. springBoot整合Spring-Data-JPA, Redis Redis-Desktop-Manager2020 windows
  3. 选择函数index_select
  4. Python 简明教程 --- 1,搭建Python 环境
  5. 9、AutoResponder返回本地数据(mock)
  6. jQuery的面试题
  7. 4.4 Go goto continue break
  8. Pyqt5_QtextEdit
  9. python遍历
  10. html5拖动监听