Cod sursa(job #61453)
| Utilizator | Data | 19 mai 2007 16:07:02 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.66 kb |
var sol,valo:array[-1..10000000]of int64;
s,i,ct:longint;
fi,fo:text;
procedure afla(s:integer);
begin
for i:=0 to 1000000 do
begin
ct:=5;
while ct<=i do
begin
sol[i]:=sol[i]+trunc(i/ct);
ct:=ct*5;
end;
if sol[i]<>sol[i-1] then valo[sol[i]]:=i;
end;
end;
begin
assign(fi,'factorial.in'); reset(fi);
assign(fo,'factorial.out'); rewrite(fo);
read(fi,s); sol[-1]:=-1;
afla(s);
if valo[s]=0 then writeln(fo,'-1') else
writeln(fo,valo[s]);
close(fi);
close(fo);
end.
