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

Why WA!?!?!?
Posted by JL Wang 10 Nov 2002 16:46
program a1047;
var
c:array[1..3000]of longint;
n,i:longint;
a0,an1,a1,s:real;
begin
    read(n);
    read(a0);
    read(an1);
    for i:=1 to n do read(c[i]);
    s:=0;
    for i:=1 to n do
        s:=s+i*c[n-i+1];
    a1:=a0+(an1-a0-2*s)/(n+1);
    writeln(a1:0:2);
end.
Re: You have a small error!
Posted by Juri Krainjukov 29 Nov 2002 01:32
> program a1047;
> var
> c:array[1..3000]of longint;
> n,i:longint;
> a0,an1,a1,s:real;
> begin
>     read(n);
>     read(a0);
>     read(an1);
>     for i:=1 to n do read(c[i]);
>     s:=0;
>     for i:=1 to n do
>         s:=s+i*c[n-i+1];

This string must look like that:
                s:=s+c[i]*(n-1+1);






>     a1:=a0+(an1-a0-2*s)/(n+1);

      ..and this one like that a1:=(an1+n*a0-2*s)/(n+1);




>     writeln(a1:0:2);
> end.