2009年2月21日 星期六

Q10014: Simple calculations

// Run time: 0.010
#include <stdio.h>
int main()
{
int num; // 輸入組數
int n;
int i; // for loop count
int weight;
double s, e; // a(0) and a(n+1)
double sum, total;

scanf("%d", &num);

while (num--)
{
sum = total = weight = 0;

scanf("%d", &n);
scanf("%lf%lf", &s, &e);

double arr[n];
for ( i = 0; i < n; i++)
scanf("%lf", &arr[i]);

sum = s*n+e;

for ( i = n-1; i >= 0; i--)
total += (weight+=2)*arr[i];

printf("%.2lf\n", (sum-total)/(n+1));

if (num)
printf("\n");
}

return 0;
}

沒有留言: