|
|
back to boardWA AGAIN!!! I'm sure in my code, BUT .... var i,j,ii,n,imin,imax,fs,fo,sfs1,sfs2,sfo1,sfo2,xx:longint; a,b,c:longint; f:array[-1000..1000] of longint; procedure readdata; begin readln(i,f[i],j,f[j],n); if i=n then begin writeln(f[i]); halt; end; if j=n then begin writeln(f[j]); halt; end; end; begin readdata; if abs(j-i)>1 then begin if i<j then begin imin:=i; imax:=j; end else begin imin:=j; imax:=i; end; ii:=imin+2; fs:=0; fo:=0; sfs1:=1; sfs2:=0; sfo1:=0; sfo2:=1; while (ii<=imax) do begin fs:=sfs1+sfs2; sfs2:=sfs1; sfs1:=fs; fo:=sfo1+sfo2; sfo2:=sfo1; sfo1:=fo; inc(ii); end; fo:=fo*f[imin]; xx:=(f[imax]-fo) div fs; end else xx:=f[imax]; if n=imin+1 then begin writeln(xx); halt; end; a:=f[imin]; b:=xx; if n>imin then for ii:=imin+2 to n do begin c:=a+b; a:=b; b:=c; end else for ii:=imin-1 downto n do begin c:=b-a; b:=a; a:=c; end; writeln(c); end. |
|
|