Cod sursa(job #203820)

Utilizator 7RaduRadu Antohi 7Radu Data 20 august 2008 09:43:52
Problema Factorial Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.9 kb
program Fact;
var
   p : longint;
   n, i, j, k : longint;
   fl : text;
function citzero(l:longint):longint;
var
   c1, c2 : longint;
begin
   citzero := 0;
   c1 := l;
   while c1 > 0 do
      begin
         c2 := c1;
           while (c2 div 5 >= 1) do
              begin
                 c2 := c2 div 5;
                 inc(citzero);
            end;
         c1 := c1-5;
     end;
end;
procedure cautabin(in1,in2:longint);
var
   x, z : longint;
begin
   x := (in1+in2) div 2;
   z := citzero(x);
   if z = p then
      begin
        x := x - (x mod 5);
        writeln(x);
         halt;
      end
   else
      if z > p then
         cautabin(1,in1-1)
      else
         cautabin(in1+1,in2);

end;
begin
   assign(fl,'fact.in');
   reset(fl);
   readln(fl,p);
   close(fl);


   assign(fl,'fact.out');
   rewrite(fl);
   cautabin(1,10000000);
   close(fl);
end.