UVA 10014(暑假-数学(3) -F - Simple calculations)

#include <cstdio>

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int n, i = 0;
		double first, last, arr[3050]; 
		scanf("%d%lf%lf", &n, &first, &last);	
		double sum = n * first + last;
		while (i < n) {
			scanf("%lf", &arr[i]);
			sum -= 2 * (n - i) * arr[i++];
		}
		printf("%0.2lf\n", sum / (n + 1));
		if (t != 0)
			printf("\n");
	}
	return 0;
}

你可能感兴趣的:(UVA 10014(暑假-数学(3) -F - Simple calculations))