#include<bits/stdc++.h> using namespace std; double n[100003]; //int time[100003]; intmain() { int N; scanf("%d",&N); for(int i=1;i<=N;i++) scanf("%lf",&n[i]); double sum=0; for(int i=1;i<=N;i++){ sum+=n[i]*i*(N-i+1);//*** } sum=(sum*100+0.5)/100; printf("%.2f\n",sum); return 0; }
The position of the asterisk in the code needs to be noted that if the integer is multiplied first and then the floating-point number is multiplied, then the amount of data of 1e5 is easy to overflow and cause an error.
Converting to floating point numbers is fine
I've been looking for a long time and I don't know what's wrong....-- I thought it was a precision pot