Floating-Point Hazard

题目描述

Given the value of low, high you will have to find the value of the following expression:

\(\sum_{i=low}^{high}(\sqrt[3]{(i+10^{-15})}-\sqrt[3]i)\)

If you try to find the value of the above expression in a straightforward way, the answer may be incorrect due to precision error.

输入

The input file contains at most 2000 lines of inputs. Each line contains two integers which denote the value of low, high (1 ≤ low ≤ high ≤ 2000000000 and high-low ≤ 10000). Input is terminated by a line containing two zeroes. This line should not be processed.

输出

For each line of input produce one line of output. This line should contain the value of the expression above in exponential format. The mantissa part should have one digit before the decimal point and be rounded to five digits after the decimal point. To be more specific the output should be of the form d.dddddE-ddd, here d means a decimal digit and E means power of 10. Look at the output for sample input for details. Your output should follow the same pattern as shown below.

样例输入

1 100
10000 20000
0 0

样例输出

3.83346E-015
5.60041E-015

题解

很有意思的求导公式,学到了

https://blog.csdn.net/wangws_sb/article/details/89676999

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define sca(x) scanf("%d",&x)
#define sca2(x,y) scanf("%d%d",&x,&y)
#define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define N 5005
const int maxn = 2000005;
double n,m;
double ans;
int cnt ;
int main()
{
while(scanf("%lf %lf",&n,&m)&&n&&m)
{
ans = 0;
rep(i,n,m+1)
ans+= 1.0/3.0*pow(double(i),-2.0/3.0);
cnt = 0;
while(ans<1)
{
ans*=10.0;
cnt--;
}
while(ans>=10)
{
ans/=10.0;
cnt++;
}
printf("%.5lfE-%03d\n",ans,15-cnt);
}
}

upc组队赛14 Floating-Point Hazard【求导】的更多相关文章

  1. upc组队赛14 Communication【并查集+floyd /Tarjan】

    Communication 题目描述 The Ministry of Communication has an extremely wonderful message system, designed ...

  2. upc组队赛12 Janitor Troubles【求最大四边形面积】

    Janitor Troubles Problem Description While working a night shift at the university as a janitor, you ...

  3. upc组队赛14 As rich as Crassus【扩展中国剩余定理】

    As rich as Crassus 题目链接 题目描述 Crassus, the richest man in the world, invested some of his money with ...

  4. upc组队赛14 Bus stop【签到水】

    Bus Stop 题目描述 In a rural village in Thailand, there is a long, straight, road with houses scattered ...

  5. upc组队赛14 Evolution Game【dp】

    Evolution Game 题目描述 In the fantasy world of ICPC there are magical beasts. As they grow, these beast ...

  6. 多项式与三角函数求导——BUAA OO 第一单元作业总结

    第一次作业 需求简要说明 针对符合规定的多项式表达式输出其符合格式规定的导函数多项式,格式错误输出WRONG FORMAT! 带符号整数 支持前导0的带符号整数,符号可省略,如: +02.-16> ...

  7. OO_BLOG1_简单表达式求导问题总结

    作业1-1 包含简单幂函数的多项式导函数的求解 I. 基于度量的程序结构分析 1)程序结构与基本度量统计图 2)分析 ​ 本人的第一次作业的程序实现逻辑十分简单,但是OOP的色彩并不强烈,程序耦合度过 ...

  8. BUAA-OO-第一单元表达式求导作业总结

    figure:first-child { margin-top: -20px; } #write ol, #write ul { position: relative; } img { max-wid ...

  9. BUAA_OO第一单元总结性博客作业——表达式求导

    一.程序设计思路 在我的三次作业中都采用了类的分层结构,采用逐项匹配,分层求导的思路. (一). 第一次作业中构建了Polynimial(多项式)类,在类的构造器中就完成了对非法空格的判断并对合法表达 ...

随机推荐

  1. Ubuntu 18.04安装docker 以及Nginx服务设置

    1.安装需要的包sudo apt install apt-transport-https ca-certificates software-properties-common curl 2.添加 GP ...

  2. 用bootstrap和css3制作按钮式下拉菜单

    利用bootstrap框架的字体图标和下拉菜单效果,以及css3的动画效果,可以做出比较优雅的按钮式下拉菜单样式 <style> .myBtnStyle .dropdown-menu sp ...

  3. kmp(暴力匹配)

    http://poj.org/problem?id=3080 Blue Jeans Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  4. seaborn教程4——分类数据可视化

    https://segmentfault.com/a/1190000015310299 Seaborn学习大纲 seaborn的学习内容主要包含以下几个部分: 风格管理 绘图风格设置 颜色风格设置 绘 ...

  5. 8、numpy——数组的迭代

    1.单数组的迭代 NumPy 迭代器对象 numpy.nditer 提供了一种灵活访问一个或者多个数组元素的方式. 迭代器最基本的任务的可以完成对数组元素的访问. 1.1 默认迭代顺序 import ...

  6. MIT 6.824学习笔记1 MapReduce

    本节内容:Lect 1 MapReduce框架的执行过程: master分发任务,把map任务和reduce任务分发下去 map worker读取输入,进行map计算写入本地临时文件 map任务完成通 ...

  7. 【学习总结】Python-3-字符串函数split()的妙用

    参考: 菜鸟教程-Python3-Python字符串-split() 语法: str.split(str="", num=string.count(str)) 参数 str -- ...

  8. 独立成分分析(Independent Component Analysis)

    ICA是一种用于在统计数据中寻找隐藏的因素或者成分的方法.ICA是一种广泛用于盲缘分离的(BBS)方法,用于揭示随机变量或者信号中隐藏的信息.ICA被用于从混合信号中提取独立的信号信息.ICA在20世 ...

  9. 1.报表TIBCO Jaspersoft Studio工具教程入门--生成jrxml和jasper文件 然后拖拽到项目中 跟ireport一样

    转自:https://blog.csdn.net/KingSea168/article/details/42553781 2. 在接下来的教程中,我们将实现一个简单的JasperReports示例,展 ...

  10. TCP和UDP的区别,以及它们对应的协议有哪些?

    TCP(传输控制协议) 是面向连接的协议.在收发数据前,一个TCP连接必须要经过“三次握手”建立可靠的连接.握手过程中传送的包里不包含数据,三次握手完毕后,客户端与服务器才正式开始传送数据.理想状态下 ...