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

Help me please, WA 11.
Posted by Denis 14 Nov 2007 22:12
Finally I've found my bug...
Be careful while doing binary search. My problem was that I couldn't find right bounds for it. Then I wrote:
l = 0;
r = 4000000000;

and in the function, which returns possibilit of such element I did such thing:
vl -= 2000000000;
I think, it'll be helpful for someone!

Edited by author 17.11.2007 01:46
i don't use binary search.
Posted by Bobur 9 Apr 2008 18:44
i don't use binary search.
i did it with maths, and DP.
but i've WA#11, pls help,
here is my code!!!
   var
   min, i, j, n, fi, fj, fn, x, y, x1, y1 : int64;
   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
             min := x;
             inc(x, y);
             y := min;
           end;
         x1 := 1;   y1 := 1;
         for k := 1 to j-n do
           begin
             min := x;
             inc(x1, y1);
             y1 := min;
           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
             min := x;
             inc(x, y);
             y := min;
           end;
         x1 := 1;   y1 := 0;
         for k := 1 to j-i do
           begin
             min := x1;
             inc(x1, y1);
             y1 := min;
           end;
         fn := TRUNC(((fj-x1*fi)*y)/y1+x*fi);
       end;
   writeLn(fn);
end.
if you know my mistake, pls help me!!!
thanks a lot