Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
公式一次AC,推公式还是比较简单的反复的代入可以推出公式 (n+1)a[i]=na[i-1]+a[i+n]-2*(c[i+n-1]+2*c[i+n-2]+3*c[i+n-3]+...+j*c[i+n-j]+...n*c[i]) 根据题意 (n+1)a[1]=na[0]+a[n+1]-2*(c[n]+2*c[n-1]+3*c[n-2]+...+j*c[n+1-j]+...n*c[1]) 代码如下: #include <stdio.h> int main () { int n,i; float a,b,c[3005],sum; while (scanf ("%d",&n)!=EOF) { sum=0; scanf ("%f%f",&a,&b); for (i=1;i<=n;i++) { scanf ("%f",&c[i]); sum+=(n-i+1)*c[i]; } sum=(n*a+b-2*sum)/(n+1); printf ("%.2f\n",sum); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator