1 50.00 25.00 10.00 2 50.00 25.00 10.00 20.00
27.50 15.00解题思路:纯粹数学题,找规律:An = (1/2)An-1 + (1/2)An+1 - CnAn-1 = (2/3)An-2 + (1/3)An+1 - (2/3)Cn - (4/3)Cn-1An-2 = (3/4)An-3 + (1/4)An+1 - (1/2)Cn - Cn-1 - (3/2)Cn-2An-3 = (4/5)An-4 + (1/5)An+1 - (2/5)Cn - (4/5)Cn-1 - (6/5)Cn-2 - (8/5)Cn-3......(是不是有点感觉了呢)接着:A1 = (n/(n+1))A0 + (1/(n+1))An+1 - (2/(n+1))Cn - (4/(n+1))Cn-1 - ... -(2n/(n+1))C1= [ nA0 + An+1 - 2(Cn + 2Cn-1 + 3Cn-2 + ... + nC1) ]/(n+1)源代码:#include <stdio.h> #include <stdlib.h> #define MaxSize 3001 int main() { int i,n; double a1,a0,end; double c[MaxSize]; while (scanf("%d",&n)!=EOF) { scanf("%lf%lf",&a0,&end); for(i=0;i<n;i++) scanf("%lf",&c[i]); a1 = n* a0 + end ; for(i=0;i<n;i++) a1-=2*(i+1)*c[n-1-i]; a1 =a1/(1 + n); printf ("%.2lf\n",a1); } system("pause"); return 0 ; }
原文地址:http://blog.csdn.net/zchlww/article/details/41726797