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 1133. Fibonacci Sequence

WA#16, i think my algo is correct
Posted by Bobur 9 Apr 2008 18:28
   var
   min, i, j, n, fi, fj, fn : integer;
   x1, y1, x, y, min1 : extended;
   k : integer;

begin
   read(i, fi, j, fj, n);
   min := i;
   if min > j then
     begin
       i := j;
       j := min;
       min := fi;
       fi := fj;
       fj := min;
     end;
     if n < i then
       begin
         x := 1;    y := 0;
         for k := 1 to i-n do
           begin
             min1 := x;
             x := x + y;
             y := min1;
           end;
         x1 := 1;   y1 := 1;
         for k := 1 to j-n do
           begin
             min1 := x1;
             x1 := x1 + y1;
             y1 := min1;
           end;
         fn := TRUNC((fj*y-fi*y1)/(x1*y+x*y1));
       end
     else
       begin
         x := 1;    y := 0;
         for k := 1 to n-i do
           begin
             min1 := x;
             x := x + y;
             y := min1;
           end;
         x1 := 1;   y1 := 0;
         for k := 1 to j-i do
           begin
             min1 := x1;
             x1 := x1 + y1;
             y1 := min1;
           end;
         fn := TRUNC(((fj-x1*fi)*y)/y1+x*fi);
       end;
   writeLn(fn);
end.
pls, help me!!

Edited by author 09.04.2008 20:26