题目链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805363914686464
思路:找规律,每次a[i]的个数都是有规律的,所以求出每次a[i]的次数就好了。
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 100100;
double a[maxn];
int main(void)
{
int n,i;
double ans=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%lf",&a[i]);
ans+=a[i]*i*(n-i+1);
}
printf("%.2lf\n",ans);
return 0;
}