当前位置:网站首页>790. 数的三次方根
790. 数的三次方根
2022-08-05 11:46:00 【aJupyter】
Question
给定一个浮点数 n,求它的三次方根。
输入格式
共一行,包含一个浮点数 n。
输出格式
共一行,包含一个浮点数,表示问题的解。
注意,结果保留 6 位小数。
数据范围
−10000≤n≤10000
输入样例:
1000.00
输出样例:
10.000000
Ideas
实数二分
Code
n = float(input())
l,r = -100,100
while (r-l) > 1e-8: # 保留x位小数 这里写1e-(x+2)
# 实数二分不要用位运算:位运算是整除
mid = (l + r) / 2
if mid**3 >= n:
r = mid
else:
l = mid
print('{:.6f}'.format(l))
边栏推荐
- shell编程流程控制练习
- 动手学深度学习_GoogLeNet / Inceptionv1v2v3v4
- Three.js 点击模型,高亮发光模型外轮廓
- Zhihu asks: Can China still achieve great national rejuvenation?
- Android development with Kotlin programming language - basic data types
- The principle and application scenario of mysql master-slave synchronization
- Learning Deep Compact Image Representations for Visual Tracking
- Android 开发用 Kotlin 编程语言一 基本数据类型
- WingIDE 7.2.0 远程调试
- Http-Sumggling Cache Vulnerability Analysis
猜你喜欢

Security Issues and Prevention in Web3

版本控制篇 | 龙智邀您共赴GOPS全球运维大会,探索大规模、敏捷、高质量、开放式的软件研发与运营之路

5G NR system messages

Naive bayes

多业务模式下的交易链路探索与实践

Qt::qcustomplot 和 qchart数据填充相关

冬日里,28℃的爱情

祝所有码农七夕快乐~
Byte Qiu Zhao confused me on both sides, and asked me under what circumstances would the SYN message be discarded?

TiDB 6.0 Placement Rules In SQL 使用实践
随机推荐
手把手教你定位线上MySQL慢查询问题,包教包会
关注微信公众号,自动登陆网站
时间格式2020-01-13T16:00:00.000Z中的T和Z分别表示什么,如何处理
Web3 中的安全问题和防范
支持向量机SVM
Gray value and thermal imaging understanding
【硬件架构的艺术】学习笔记(2)同步和复位
623. Add a row to a binary tree: Simple binary tree traversal problems
Gao Zelong attended the Boao Global Tourism Ecology Conference to talk about Metaverse and Future Network Technology
Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4
冬日里,28℃的爱情
The importance of parameter naming, remember a JDBC parameter conflict
How to write a blog with Golang - Milu.blog development summary
“小钢炮”气质明显,安全、舒适一个不落
【HMS core】【FAQ】Health Kit、Ads kit、push Kit典型问题合集5
Machine Learning - Ensemble Learning
The principle and application scenario of mysql master-slave synchronization
内存问题难定位,那是因为你没用ASAN
hdu1455 Sticks (search+pruning+pruning+.....+pruning)
todolist案列——原生js