题意
-
求:
∑ i = l o w h i g h ( i + 1 0 − 15 3 − i 3 ) \sum_{i=low}^{high} (\sqrt[3]{i+10^{-15}}-\sqrt[3]i) i=low∑high(3i+10−15−3i) -
T ≤ 2000 , 1 ≤ l o w , h i g h ≤ 2 × 1 0 9 , h i g h − l o w ≤ 1 0 4 T\le 2000,1\le low,high\le 2\times10^9,high-low\le 10^4 T≤2000,1≤low,high≤2×109,high−low≤104
思路
-
1 0 − 15 10^{-15} 10−15 是一个很小的量,可以联想到 d x dx dx,写出求导公式:
f ( x ) = x 3 f ′ ( x ) = x + d x 3 − x 3 d x = 1 3 x − 2 3 x + d x 3 − x 3 = 1 3 x − 2 3 d x \begin{aligned} f(x)&=\sqrt[3]{x}\\ f'(x)&=\dfrac{\sqrt[3]{x+dx}-\sqrt[3]x}{dx}=\frac{1}{3}x^{-\frac{2}{3}}\\ \sqrt[3]{x+dx}-\sqrt[3]x&=\frac{1}{3}x^{-\frac{2}{3}}dx \end{aligned} f(x)f′(x)3x+dx−3x=3x=dx3x+dx−3x=31x−32=31x−32dx -
带入 d x = 1 0 − 15 dx=10^{-15} dx=10−15,注意转一下科学计数法
代码
int low, high;
void solve() {
long double res = 0;
rep(i, low, high) res += pow(i * 1.0, -2.0 / 3.0);
res /= 3;
int tot = 15;
while(res < 1.0) res = res * 10.0, ++tot;
while(res >= 10.0) res = res / 10.0, --tot;
if(tot < 10) printf("%.5LfE-00%d\n", res, tot);
else if(tot >= 100) printf("%.5LfE-%d\n", res, tot);
else printf("%.5LfE-0%d\n", res, tot);
}
int main() {
while(scanf("%d%d", &low, &high) && (low || high)) solve();
return 0;
}