其他分享
首页 > 其他分享> > Floating-Point Hazard (数学)

Floating-Point Hazard (数学)

作者:互联网

https://vj.z180.cn/c7965da2b8fbd28dfbce93c000a232e5?v=1578704227

题意:

高精度求和

思路:

用求导定义得出所求式子可化为对i^(1/3)求导的和*1e5,即求1/3*i^(-2/3)的和*1e15

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <math.h>
 4 
 5 int main()
 6 {
 7     int i, low, high, num;
 8     double sum;
 9     while(~scanf("%d %d", &low, &high)&&low&&high)
10     {
11         sum = 0.0;
12         for(i=low; i<=high; i++)
13         {
14             sum = sum + pow(i, -2.0 / 3.0) / 3.0;
15         }
16         num = 15;
17         while(sum < 1)
18         {
19             sum *= 10;
20             num++;
21         }
22         while(sum > 10)
23         {
24             sum /= 10;
25             sum--;
26         }
27         printf("%.5lfE-%03d\n", sum, num);
28     }
29     return 0;
30 }

标签:10,Point,int,sum,Hazard,high,low,Floating,include
来源: https://www.cnblogs.com/0xiaoyu/p/12181941.html