Cod sursa(job #282380)
| Utilizator | Data | 17 martie 2009 16:32:46 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 1.41 kb |
var i,aux2,aux5,p,aux:longint;
f:text;
begin
assign(f,'fact.in');
reset(f);
read(f,p);
close(f);
if p=0 then begin
assign(f,'fact.out');
rewrite(f);
write(f,1);
close(f);
halt;
end
else if p=1 then begin
assign(f,'fact.out');
rewrite(f);
write(f,5);
close(f);
halt;
end
else begin
i:=0;
aux2:=0;
aux5:=0;
while (aux2<=p) or (aux5<=p) do
begin
inc(i);
aux:=i;
while aux mod 2=0 do begin
aux:=aux div 2;
inc(aux2);
end;
while aux mod 5=0 do begin
aux:=aux div 5;
inc(aux5);
end;
if (aux5>=p) and (aux2>=p) then begin
assign(f,'fact.out');
rewrite(f);
write(f,i);
close(f);
halt;
end;
end;
end;
assign(f,'fact.out');
rewrite(f);
write(f,-1);
close(f);
end.