|
|
back to boardHelp! My program got Memory Limit! This is my program: var a,c:array [0..3001] of real; n:integer; procedure init; var i:integer; begin read(n); read(a[0],a[n+1]); for i:=1 to n do read(c[i]); end; function work(i:integer):real; begin if i=0 then work:=a[0] else if i=n+1 then work:=a[n+1] else work:=(work(i-1)+work(i+1))/2-c[i]; end; procedure print; begin writeln(work(1):0:2); end; begin init; print; end. Re: Help! My program got Memory Limit! Your algoritmh not correct again. It very long. This problem solve with other algoritmh. Used that a[0] = 2*a[1] + 2*c[1] - a[2] = 3*a[2] - 2*a[3] + 2*c[1] + 4*c[2], etc. |
|
|