您的位置:首页 > 其它

UVA - 10014 Simple calculations

2014-10-08 00:08 351 查看
#include<cstdio>

int main() {
	int test, n ;
	double first,last, sum  , temp, ans;
	scanf("%d", &test);

	while(test--) {
		scanf("%d", &n);
		scanf("%lf", &first);
		scanf("%lf", &last);
		sum = 0;	
		for(int i = 1; i <= n; i++) {
			scanf("%lf", &temp);
			sum  = sum + 2.0*(n+1-i)*temp;	
		}
		double a = n * first + last - sum;
		printf("%.2lf\n", a / (n+1));
		if(test != 0 )
			printf("\n");	
	}
	return 0;
}


题目大意:根据所给的公式求出a1

解題思路:找到公式就可以
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: