传送门UVa 10014 - Simple calculations
数列题.
推倒的过程就不详细说了, 第一步先推到
然后我就卡在这里了.
其实这里还可以往下推.
取n = 1, 2, 3.....n相加, 最后得到
OK.
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
int T, n, cnt = 1;
double a, b;
register double sum, tempSum, temp; //这里用register比普通的double快0.012s
register int i;
scanf("%d", &T);
while (T--)
{
if (cnt > 1)
printf("\n");
cnt++;
sum = tempSum = 0;
scanf("%d%lf%lf", &n, &a, &b);
for (i = 0; i < n; i++)
{
scanf("%lf", &temp);
tempSum += temp;
sum += tempSum;
}
printf("%.2f\n", (n * a - 2 * sum + b) / (n + 1));
}
return 0;
}