当前位置:网站首页>acwing 790. The cubic root of a number (floating-point number in half)
acwing 790. The cubic root of a number (floating-point number in half)
2022-06-12 16:18:00 【_ Liuxiaoyu】
Given a floating-point number n, Find its third root .
Input format
All in one line , Contains a floating-point number n.
Output format
All in one line , Contains a floating-point number , Represents the solution of the problem .
Be careful , The result is reserved 6 Decimal place .
Data range
−10000≤n≤10000
sample input :
1000.00
sample output :
10.000000
Ideas : Just two points
Remember to use the variable double type
Picture understanding :
#include <iostream>
using namespace std;
int main()
{
double x;
cin >> x;
double l = -10000, r = 10000; // Take the range of the result directly
while(r - l > 1e-8) // Empirical value : If you keep a few decimal places , Once again, add 2 The negative power of
{
double mid = (l + r) / 2; // There can no longer be int Variable
if( mid * mid * mid >= x) r = mid;
else l = mid;
}
printf("%lf\n", r); // Write here l perhaps r Will do
return 0;
}
边栏推荐
- Analysis of China's cargo transport volume, cargo transport turnover and port cargo in 2021 [figure]
- Project training of Software College of Shandong University rendering engine system basic renderer (IV)
- [weekly replay] game 80 of leetcode
- Homology? Cross domain? How to solve cross domain problems?
- What is JUC in high concurrency programming
- 面试:hashCode()和equals()
- Let's talk about events. Listen to those things. - Part one
- acwing 高精度乘法
- 一步步创建包含自定义 Screen 的 ABAP 程序的详细步骤试读版
- 当编程纳入到高考。。。
猜你喜欢

一步步创建包含自定义 Screen 的 ABAP 程序的详细步骤试读版

acwing 801. 二进制中1的个数(位运算)

批量--04---移动构件

Redis General Command

Project training of Software College of Shandong University rendering engine system basic renderer (III)

Unicom Network Management Protocol block diagram

acwing 803. Interval merging

acwing 800. 数组元素的目标和

鼻孔插灯,智商上升,风靡硅谷,3万就成

IDEA中文棱形乱码错误解决方法--控制台中文输出棱形乱码
随机推荐
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.5 实例(fopen 和 getc 函数的实现)
acwing794 高精度除法
Step by step steps to create an ABAP program with a custom screen
面试:了解装箱和拆箱操作吗?
Acwing795 prefix sum (one dimension)
Analysis on the current situation of China's antiarrhythmic drug industry in 2021: domestic R & D is further [figure]
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.6 实例(目录列表)
Homology? Cross domain? How to solve cross domain problems?
The C Programming Language(第 2 版) 笔记 / 8 UNIX 系统接口 / 8.1 文件描述符
< 山东大学软件学院项目实训 > 渲染引擎系统——辐射预计算(八)
< 山东大学软件学院项目实训 > 渲染引擎系统——基础渲染器(三)
5-5 configuring MySQL replication log point based replication
The market share of packaged drinking water has been the first for eight consecutive years. How does this brand DTC continue to grow?
Acwing high precision multiplication
When programming is included in the college entrance examination...
IDEA中文棱形乱码错误解决方法--控制台中文输出棱形乱码
盒马,最能代表未来的零售
连续八年包装饮用水市占率第一,这个品牌DTC是如何持续增长的?
acwing 801. 二进制中1的个数(位运算)
Project training of Software College of Shandong University rendering engine system basic renderer (V)