POJ 2601
1 #include<iostream> 2 #include<iomanip> 3 #include<stdio.h> 4 using namespace std; 5 6 int main() 7 { 8 //freopen("acm.acm","r",stdin); 9 int n; 10 int i; 11 double * a; 12 double * c; 13 cin>>n; 14 a = new double[n+2]; 15 c = new double[n]; 16 17 cin>>a[0]>>a[n+1]; 18 for(i = 0; i < n; ++ i) 19 { 20 cin>>c[i]; 21 } 22 a[1] = n*a[0] + a[n+1]; 23 for(i = 0; i < n; ++ i) 24 { 25 a[1] -= 2*(n - i)*c[i]; 26 } 27 cout<<setiosflags(ios::fixed)<<setprecision(2)<<a[1]/(n+1)<<endl; 28 }