public class Solution {
public int MySqrt(int x) {
long r = x;
while (r * r > x)
r = (r + x / r) / ;
return (int)r;
}
}

https://leetcode.com/problems/sqrtx/#/description

补充一个python的实现:

 class Solution:
def mySqrt(self, x: int) -> int:
r = x
while r * r > x:
r = (r + x // r) //
return int(r)

使用内置函数:

 class Solution:
def mySqrt(self, x: int) -> int:
return int(x ** 0.5)

最新文章

  1. 【hihoCoder】1121:二分图一·二分图判定
  2. 操作系统开发系列—10.内核HelloWorld ●
  3. Avalon学习
  4. HDU 4417 (划分树+区间小于k统计)
  5. 常用的正则表达式归纳—JavaScript正则表达式
  6. 【OpenCV学习笔记】之六 手写图像旋转函数---万丈高楼平地起
  7. -_-#【Canvas】measureText, translate, drawImage
  8. nginx gzip on
  9. myeclipse乱码问题和 编码设置
  10. oracle中row_number() over()
  11. 使用Visual Studio Team Services持续集成(四)——使用构建运行测试
  12. mysql设置对外访问
  13. 第 15 章 位操作(invert4)
  14. [leetcode]Sqrt(x) @ Python
  15. OAF_OAF控件系列4 - HGrid的实现(案列)
  16. Mycat跨分片Join
  17. postman 查看请求,已各种语言方式展示:
  18. C/C++ 标准
  19. 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderList
  20. 学习神器!本机安装虚拟机,并安装Linux系统,并部署整套web系统手册(包含自动部署应用脚本,JDK,tomcat,TortoiseSVN,Mysql,maven等软件)

热门文章

  1. poj3281网络流之最大流
  2. 【hive】时间段为五分钟的统计
  3. json.dumps与json.dump的区别 json.loads与json.load的区别(简洁易懂)
  4. maven+jmeter+jenkins集成
  5. redux中的compose源码分析
  6. antd中form自定义rules
  7. IO综合练习--文件切割和文件合并
  8. Codeforces 1006C:Three Parts of the Array(前缀和+map)
  9. 【传输协议】https SSL主流数字证书都有哪些格式?
  10. android高速上手(三)经常使用控件使用