Floating-Point Hazard (数学)
https://vj.z180.cn/c7965da2b8fbd28dfbce93c000a232e5?v=1578704227
题意:
高精度求和
思路:
用求导定义得出所求式子可化为对i^(1/3)求导的和*1e5,即求1/3*i^(-2/3)的和*1e15
#include <stdio.h> #include <string.h> #include <math.h> int main() { int i, low, high, num; double sum; while(~scanf("%d %d", &low, &high)&&low&&high) { sum = 0.0; for(i=low; i<=high; i++) { sum = sum + pow(i, -2.0 / 3.0) / 3.0; } num = 15; while(sum < 1) { sum *= 10; num++; } while(sum > 10) { sum /= 10; sum--; } printf("%.5lfE-%03d\n", sum, num); } return 0; }
相关推荐
xceman 2020-10-13
算法与数学之美 2020-10-07
Anscor 2020-10-05
liwg0 2020-09-08
数学爱好者 2020-08-31
thermodynamicB 2020-08-11
夕加加 2020-07-20
willowwgx 2020-07-18
kuoying 2020-07-16
Anscor 2020-07-14
starletkiss 2020-07-08
kingzone 2020-06-27
xceman 2020-06-27
算法与数学之美 2020-06-21
kuoying 2020-06-21
秒懂数学 2020-06-17