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. 1 100
  2. 10000 20000
  3. 0 0

样例输出

  1. 3.83346E-015
  2. 5.60041E-015

题解

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

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

代码

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define rep(i,a,n) for(int i=a;i<n;i++)
  4. #define scac(x) scanf("%c",&x)
  5. #define sca(x) scanf("%d",&x)
  6. #define sca2(x,y) scanf("%d%d",&x,&y)
  7. #define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
  8. #define scl(x) scanf("%lld",&x)
  9. #define scl2(x,y) scanf("%lld%lld",&x,&y)
  10. #define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
  11. #define pri(x) printf("%d\n",x)
  12. #define pri2(x,y) printf("%d %d\n",x,y)
  13. #define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
  14. #define prl(x) printf("%lld\n",x)
  15. #define prl2(x,y) printf("%lld %lld\n",x,y)
  16. #define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
  17. #define ll long long
  18. #define LL long long
  19. #define pb push_back
  20. #define mp make_pair
  21. #define P pair<int,int>
  22. #define PLL pair<ll,ll>
  23. #define PI acos(1.0)
  24. #define eps 1e-6
  25. #define inf 1e17
  26. #define INF 0x3f3f3f3f
  27. #define N 5005
  28. const int maxn = 2000005;
  29. double n,m;
  30. double ans;
  31. int cnt ;
  32. int main()
  33. {
  34. while(scanf("%lf %lf",&n,&m)&&n&&m)
  35. {
  36. ans = 0;
  37. rep(i,n,m+1)
  38. ans+= 1.0/3.0*pow(double(i),-2.0/3.0);
  39. cnt = 0;
  40. while(ans<1)
  41. {
  42. ans*=10.0;
  43. cnt--;
  44. }
  45. while(ans>=10)
  46. {
  47. ans/=10.0;
  48. cnt++;
  49. }
  50. printf("%.5lfE-%03d\n",ans,15-cnt);
  51. }
  52. }

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. sqlite查询语句

    搜索距现在六个月前的月份第一天日期: SELECT date('now','start of month','-6 month','0 day'); 搜索距现在六个月前的日期: SELECT date ...

  2. js字符串相关方法

    <script> // 使用索引位置来访问字符串中的每个字符: var carname = 'Volvo XC60'; var character = carname[7]; consol ...

  3. CSS-06 外部JS,CSS文件的寻址问题

    如果js.css外部文件有使用到相对路径,其相对路径的基准是不一样的 当一个index.html中引入外部的JS和CSS文件时: 在index.css文件中,相对路径的写法是以css文件相对于img图 ...

  4. iOS crash log 解析

    iOS开发中,经常遇到App在开发及测试时不会有问题,但是装在别人的设备中会出现各种不定时的莫名的 crash,因为iOS设备会保存应用的大部分的 crash Log,所以可以通过 crash Log ...

  5. 前端学习(三十五)模块化es6(笔记)

    RequireJs:一.安装.下载    官网: requirejs.org    Npm:  npm i requirejs二.使用    以前的开发方式的问题:        1).js 是阻塞加 ...

  6. Flutter第三方選擇器組件

    调用Flutter的第三方时间选择器组件 上面我介绍了系统给我们提供的日期时间选择器,但是有时候系统提供的选择器并不符合我们的要求,这时我们就可以到pub.dev上去寻找符合我们要求的日期选择器. 这 ...

  7. Python格式输出汇总

    print ('%10s'%('test')) print ('{:<10}'.format('test'))#left-aligned print ('{:>10}'.format('t ...

  8. [USACO10FEB] 吃巧克力Chocolate Eating (二分答案)

    题目链接 Solution 先直接二分答案,然后贪心判断,一旦少于答案就吃一块. 思路很简单,有一点细节. 一天内可以不吃巧克力. 注意处理最后时没吃完的全部在最后一天吃完. Code #includ ...

  9. delphi+mysql做的图书管理系统,怎么把mysql数据库也一起打包进去?我用的是delphi的Express组件。

    sqlconnection,sqlquery1这些组件,我连接数据库的时候是用对象编辑器里的属性进行连接的,在sqlconnection中指定了字符集utf8,有些人做的方法是利用代码连接的数据库,如 ...

  10. BUUCTF | CODE REVIEW 1 (反序列化,md5绕过)

    <?php /** * Created by PhpStorm. * User: jinzhao * Date: 2019/10/6 * Time: 8:04 PM */ highlight_f ...