您的位置:首页 > 其它

UVa 10014 - Simple calculations

2013-07-08 17:48 183 查看
/*
推导出公式: a1 = (an+1 + n*a0 - 2Sn)/(n+1), 其中Sn = T1 + T2 + .. + Tn, Tn = c1 + .. + cn
*/
#include <cstdio>
#include <cmath>

int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
int T;
scanf("%d", &T);
while(T--) {
int n;
double a, b;
scanf("%d%lf%lf", &n, &a, &b);
double s = 0, t = 0, c;
for(int i=0; i<n; i++) {
scanf("%lf", &c);
t += c;
s += t;
}
s = (b + n*a - 2*s)/(n+1);
printf("%.2lf\n", s);
if(T) printf("\n");
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: