Cod sursa(job #100194)
| Utilizator | Data | 11 noiembrie 2007 23:13:56 | |
|---|---|---|---|
| Problema | Factorial | Scor | 15 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.7 kb |
var p,p2,c,n2,n,n3,x:longint ;f,g:text;
begin
assign(f,'fact.in'); reset(f);
assign(g,'fact.out');rewrite(g);
read(f,p);
c:=1;
n:=2000000000;
n2:=n; p2:=0;
if p>0 then begin
while p2<>p do begin
if (p2>p) then
n2:=(c+n2-1) div 2
else if p2<>0 then begin
c:=n2;
n2:=n3;
n2:=(c+n2-1) div 2;
end;
x:=5; p2:=0;
while n2 div x>0 do begin
p2:=p2+n2 div x;
x:=x*5;
end;
if p2>p then n3:=n2
end;
writeln(g,n2);
end
else write('-1');
close(g);
end.
