当前位置:网站首页>790. 数的三次方根
790. 数的三次方根
2022-08-02 02:20:00 【Hunter_Kevin】
题目
给定一个浮点数 n,求它的三次方根。
输入格式
共一行,包含一个浮点数 n。
输出格式
共一行,包含一个浮点数,表示问题的解。
注意,结果保留 6 位小数。
数据范围
−10000≤n≤10000
输入样例:
1000.00
输出样例:
10.000000
代码
#include <iostream>
using namespace std;
int main()
{
double n;
cin >> n;
double l = -1e5, r = 1e5;
while(r-l > 1e-8){
double mid = (l+r)/2;
if(mid*mid*mid >= n) r = mid;
else l = mid;
}
printf("%.6lf\n",l);
return 0;
}
边栏推荐
- ¶ Backtop back to the top is not effective
- [LeetCode Daily Question] - 103. Zigzag Level Order Traversal of Binary Tree
- 【Unity入门计划】2D Game Kit:初步了解2D游戏组成
- AWR analysis report questions for help: How can SQL be optimized from what aspects?
- Safety (2)
- Use baidu EasyDL implement factory workers smoking behavior recognition
- Redis for distributed applications in Golang
- Constructor instance method inheritance of typescript37-class (extends)
- Reflex WMS Intermediate Series 7: What should I do if I want to cancel the picking of an HD that has finished picking but has not yet been loaded?
- ALCCIKERS Shane 20191114
猜你喜欢

The Paddle Open Source Community Quarterly Report is here, everything you want to know is here

Handwritten Blog Platform ~ Day Two

The underlying data structure of Redis

BioVendor人俱乐部细胞蛋白(CC16)Elisa试剂盒研究领域

Software testing Interface automation testing Pytest framework encapsulates requests library Encapsulates unified request and multiple base path processing Interface association encapsulation Test cas

【web】Understanding Cookie and Session Mechanism

openGauss切换后state状态显示不对

Chopper webshell feature analysis

Scheduled tasks for distributed applications in Golang

FOFAHUB使用测试
随机推荐
Golang分布式应用之Redis
Rasa 3.x 学习系列- Rasa - Issues 4873 dispatcher.utter_message 学习笔记
The first time I wrote a programming interview question for Niu Ke: input a string and return the letter with the most occurrences of the string
swift project, sqlcipher3 -> 4, cannot open legacy database is there a way to fix it
openGauss切换后state状态显示不对
垃圾回收器CMS和G1
leetcode / anagram in string - some permutation of s1 string is a substring of s2
CodeTon Round 2 D. Magical Array 规律
Oracle19c安装图文教程
BI - SQL 丨 WHILE
LeetCode 213. Robbery II (2022.08.01)
Check if IP or port is blocked
一次SQL优化,数据库查询速度提升 60 倍
字典常用方法
Handwritten Blog Platform ~ Day Two
oracle查询扫描全表和走索引
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
Fundamentals of Cryptography: X.690 and Corresponding BER CER DER Encodings
力扣、752-打开转盘锁
MySQL optimization strategy