标签:
HDOJ题目地址:传送门
1 50.00 25.00 10.00 2 50.00 25.00 10.00 20.00
27.50 15.00
因为:Ai=(Ai-1+Ai+1)/2 - Ci,
#include <iostream> #include <cstdio> using namespace std; int main (){ int i,j,n; double sum; while (scanf("%d",&n)!=EOF){ sum=0; double a[3500],c[3500],d; scanf("%lf%lf",&a[0],&a[n+1]); for (i=1; i<=n; i++) scanf("%lf",&c[i]); a[1]=n*a[0]+a[n+1]; for (i = n, j = 1; i >=1&&j <= n; j++,i--) sum += i*c[j]; a[1] = (a[1] - 2*sum)/(n+1); printf ("%.2lf\n",a[1]); } return 0; }
标签:
原文地址:http://blog.csdn.net/qq_26891045/article/details/51505954