当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

Handwritten Blog Platform ~ Day Two

The underlying data structure of Redis

2022河南青训联赛第(三)场

2022-07-30 mysql8执行慢SQL-Q17分析

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?

工程师如何对待开源

Unable to log in to the Westward Journey

接口测试神器Apifox究竟有多香?

Project Background Technology Express

AOF rewrite
随机推荐
垃圾回收器CMS和G1
Project Background Technology Express
Nanoprobes丨1-mercapto-(triethylene glycol) methyl ether functionalized gold nanoparticles
Oracle19c安装图文教程
【ORB_SLAM2】void Frame::AssignFeaturesToGrid()
2022-08-01 安装mysql监控工具phhMyAdmin
LeetCode刷题日记:34、 在排序数组中查找元素的第一个和最后一个位置
2022-08-01 Reflection
LeetCode brush diary: LCP 03. Machine's adventure
菜刀webshell特征分析
【LeetCode每日一题】——103.二叉树的锯齿形层序遍历
项目后台技术Express
Constructor instance method inheritance of typescript37-class (extends)
记一个gorm初始化的坑
Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
【web】Understanding Cookie and Session Mechanism
Nanoprobes丨1-巯基-(三甘醇)甲醚功能化金纳米颗粒
AntPathMatcher uses
AOF rewrite
字典常用方法