杭电2086 A=?

  1.  # include <iostream>
  2. # include <cstdio>
  3. using namespace std;
  4. int main(){
  5. int n,i,j;
  6. double  a[2],b[50000],k;
  7. while(cin>>n){
  8. cin>>a[0]>>a[1];
  9. for(i=0;i<n;i++){
  10. cin>>b[i];
  11. }
  12.  
  13. double sum = 0;
  14. sum = 1.0*n/(n+1)*a[0] + 1.0/(n+1)*a[1];
  15. k = 1.0*n*2;
  16. for(j=0;j<n;j++){
  17. sum -= k/(n+1)*b[j];
  18. k-=2.0;
  19. }
  20. printf("%.2lf\n",sum);
  21. }
  22. return 0;
  23. }

你可能感兴趣的:(递推)