Why I got "Wrong Answer"?
Posted by
qwt 27 May 2002 16:13
{$N+}
var
aa,ab,ba,bb,a,b,c1,c2,ff,fi,fj:extended;
t,i,j,k:longint;
function cf(x:extended;n:longint):extended;
var
i:integer;
j:extended;
begin
j:=1;
for i:=1 to n do j:=j*x;
cf:=j;
end;
begin
a:=(1+sqrt(5))/2;
b:=(1-sqrt(5))/2;
readln(i,fi,j,fj,k);
t:=maxlongint;
if t>i then t:=i;
if t>j then t:=j;
if t>k then t:=k;
dec(i,t-1);dec(j,t-1);dec(k,t-1);
aa:=cf(a,i);ab:=cf(b,i);
ba:=cf(a,j);bb:=cf(b,j);
c2:=(fi*ba-fj*aa)/(ab*ba-bb*aa);
c1:=(fi-c2*ab)/aa;
ff:=c1*cf(a,k)+c2*cf(b,k);
writeln(ff:0:0);
end.