Created
February 10, 2014 07:19
-
-
Save KT-Yeh/8911711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
double a0,an1,c[3010]; | |
int Case, N; | |
double sum_c() | |
{ | |
double sum = 0; | |
for (int i = 1, j = N; i <= N; i++, j--) | |
sum += (c[i] * j); | |
return sum; | |
} | |
int main() | |
{ | |
scanf("%d", &Case); | |
while (Case--){ | |
scanf("%d", &N); | |
scanf("%lf %lf", &a0, &an1); | |
for (int i = 1; i <= N; i++) | |
scanf("%lf",&c[i]); | |
printf("%.2f\n", (N * a0 + an1 - 2 * sum_c()) / (N+1)); | |
if (Case) printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment