我按三角形来计算的时候例如
0.1
0.1 0.2
0.1 0.2 0.3
0.1 0.2 0.3 0.4、
0.2
0.2 0.3
0.2 0.3 0.4
0.3
0.3 0.4
0.4
估计计算的精度会出现问题。会有一个不能AC/
按照大神们的计算方法可以AC。。到时候再查查什么地方出了问题。
#include <iostream>
#define MAX 100010
using namespace std;
int n;
int main() {
cin >> n;
double temp,sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%lf", &temp);
sum += temp * i * (n - i + 1);
}
printf("%.2lf\n", sum);
return 0;
}