Cod sursa(job #60224)
| Utilizator | Data | 13 mai 2007 10:33:38 | |
|---|---|---|---|
| Problema | Factorial | Scor | 20 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.72 kb |
var
p:int64;
procedure calc;
var
c,i,d,z:int64;
begin
i:=1;
c:=0;
d:=0;
while (c<p) or (d<p) do
begin
c:=0;
d:=0;
inc(i);
z:=i;
while z div 5 > 0 do
begin
inc(c, z div 5);
z:= z div 5;
end;
z:=i;
while z div 2 > 0 do
begin
inc(d, z div 2);
z:= z div 2;
end;
end;
if (c=p) or (d=p) then writeln(i) else writeln('-1');
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
while not eof do
begin
readln(p);
calc;
end;
close(output);
end.
