|
|
back to boardWhy 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! > 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. |
|
|