Given the value of low, high you will have to find the value of the following expression:
给你下界和上界的值,你得算出以下表达式的值:
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.
输入文件包含至多2000条输入,每一行包含两个整数,代表下界和上界。输入以一行内的两个0结束,并不作处理。
输出
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.
对于每一组输入,输出一行答案。这行内应当包含一个以指数形式(科学计数法)表示的求得的上述表达式的值。尾数部分应当在保留一位数字,并在小数点后保留五位小数。更准确的说输出应当是d.dddddE-ddd的形式,d代表一个数字,e代表10的幂。细节部分请观察样例输出。你的输出应该和下列的样例模式上对应。
输入
1 100
10000 20000
0 0
输出
3.83346E-015
5.60041E-015
这个题每个高中毕业的人都会做,只不过这个题干不说人话罢了。以我们熟悉的形式翻译一下:
给定函数:,设该函数在定义域上连续可导,给定区间上界为b,下界为a。
对于任意整数x∈[a,b],当x从a连续变化到b时,求的函数值的和。
这个原函数的形式像极了导数定义式的上半部分:,当趋近于无穷小时,我们称此处的值为函数f(x)在x处的导数。根据原式,我们断定,由于这个数足够小,我们可以认为其为无穷小。
根据求导公式可知:,两边同乘可以得到原表达式,对整式右边的函数进行计算即可。
所以有如下思路:
- 求得等价函数,进行求和
- 将求得的和进行处理,直至满足答案形式
代码如下:
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <stack>
#include <iomanip>
#include <cstring>
#include <cmath>
#define DETERMINATION main
#define lldin(a) scanf("%lld",&a)
#define din(a) scanf("%d",&a)
#define printlnlld(a) printf("%lld\n",a)
#define printlnd(a) printf("%d\n",a)
#define printlld(a) printf("%lld",a)
#define printd(a) printf("%d",a)
#define reset(a,b) memset(a,b,sizeof(a))
const long long int INF=0x3f3f3f3f;
using namespace std;
const double PI=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int mod=1000000007;
const int tool_const=1999112620000907;
const int tool_const2=33;
inline ll lldcin()
{
ll tmp=0,si=1;
char c=getchar();
while(c>'9'||c<'0')
{
if(c=='-')
si=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
tmp=tmp*10+c-'0';
c=getchar();
}
return si*tmp;
}
///Schlacht von Stalingrad
/**Although there will be many obstructs ahead,
the desire for victory still fills you with determination..**/
int DETERMINATION()
{
ll x1,x2;
while(cin>>x1>>x2&&(x1+x2))
{
ld sum=0;
for(int i=x1;i<=x2;i++)
sum+=pow(i,-2.0/3)/3;
ll final_power=15;//这是最后的指数
while(sum>10)
{
final_power--;
sum/=10;
}
while(sum<1)
{
final_power++;
sum*=10;
}
cout<<fixed<<setprecision(5)<<sum<<"E-";
cout<<setw(3)<<setfill('0')<<final_power<<endl;
}
return 0;