# A1 = ?

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3038    Accepted Submission(s): 1910

Problem Description

Input

Output

Sample Input
1 50.00 25.00 10.00 2 50.00 25.00 10.00 20.00
Sample Output
27.50 15.00

=>A1+A2 = (A0+A2+A1+A3)/2 - (C1+C2)
=>A1+A2 = A0+A3 - 2(C1+C2)

A1+A2 = A0+A3 - 2(C1+C2)
A1+A3 = A0+A4 - 2(C1+C2+C3)
A1+A4 = A0+A5 - 2(C1+C2+C3+C4)
...
A1+An = A0+An+1 - 2(C1+C2+...+Cn)
A1+A1 = A0+A2 - 2(C1) (本来就是)
----------------------------------------------------- 左右求和
(n+1)A1+(A2+A3+...+An) = nA0 +(A2+A3+...+An) + An+1 - 2(nC1+(n-1)C2+...+2Cn-1+Cn)
=> (n+1)A1=nA0 + An+1 - 2(nC1+(n-1)C2+...+2Cn-1+Cn)
=> A1 = [nA0 + An+1 - 2(nC1+(n-1)C2+...+2Cn-1+Cn)]/(n+1)

#include<stdio.h>
int main()
{
double m,n,sum,c[5000];
int i,t;
while(scanf("%d",&t)!=EOF)
{
scanf("%lf%lf",&m,&n);
for(i=1,sum=0;i<=t;i++)
{
scanf("%lf",&c[i]);
sum+=c[i]*(t-i+1);
}
sum=1.0*(t*m+n-2*sum)/(t+1);

printf("%.2lf\n",sum);
}
return 0;
}

posted on 2012-07-12 20:46 天YU地___PS，代码人生 阅读(61) 评论(0)  编辑  收藏

 只有注册用户登录后才能发表评论。 网站导航:
 < 2012年7月 >
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

一定要好好学习，天天向上!

•