ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1047. Simple Calculations

Please help ... What's wrong with this piece of code ? ...
Posted by Damboiu Mihai 6 Oct 2002 04:59
program p1047(input,output);

const MAX=3000;
var n,i : integer;
    a0,a1,an1,S : real;
    c : array[1..MAX] of real;

begin
    ReadLn(n);
    ReadLn(a0);
    ReadLn(an1);
    for i:=1 to n do
     ReadLn(c[i]);
    if n>1 then
     begin
      S:=c[1]+c[2];
      i:=3;
      while i<=n do
       begin
        S:=S*2.0+c[i];
        i:=i+1;
       end;
     a1:=(n*a0+an1-2.0*(S+c[1]))/(n+1);
     end
    else
     a1:=(a0+an1)/2.0-c[1];
    WriteLn(a1:6:2);
end.