可以推导出:A1 = n / (n + 1) * A0 + 1 / (n + 1)* An+1 - 2*n / (n + 1)* C1 - (2*n - 2)/(n + 1)* C2 - ........2 / (n + 1)* Cn-1。
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
double Ao, An;
double num[3005];
while(scanf("%d", &n) != EOF)
{
scanf("%lf%lf", &Ao, &An);
for(int i = 1; i <= n; i++)
scanf("%lf", &num[i]);
double ans = double(n) / double(n + 1) * Ao + 1.0 / (n + 1) * An;
double k = double(n) * 2.0;
for(int j = 1; j <= n; j++)
{
ans -= k / (n + 1) * num[j];
k -= 2.0;
}
printf("%.2lf\n", ans);
}
return 0;
}