Cod sursa(job #557783)

Utilizator vladch93Vlad Chereches vladch93 Data 16 martie 2011 20:58:19
Problema Factorial Scor 10
Compilator fpc Status done
Runda Arhiva de probleme Marime 1.02 kb
program fact;
var f : text;
    p, n, k, x, l : longint;
begin
assign (f, 'fact.in');
reset (f);
read (f, p);
close (f);
assign (f, 'fact.out');
rewrite (f);
x:=1;
k:=0;
if p>0 then
repeat
 if p*5>=x then begin
                x:=x*5;
                inc (k);
               end;
until p*5<=x;
l:=p*5-(k-2)*5;
{if p>0 then
repeat
 k:=k+5;
 inc (l);
 if (k mod 10<>0) and (k mod 5=0) then begin
                                        x:=k div 5;
                                        while (x mod 5=0) and (l<p) do begin
                                                                        inc (l);
                                                                        x:=x div 5;
                                                                       end;
                                       end;
until l=p;               }
if p=0 then write (f, 1)
       else if p=5 then write (f, -1)
                   else if p=1 then write (f, 5)
                               else write (f, l);
close (f);
end.