Pagini recente » Rezultatele filtrării | Rezultatele filtrării | Cod sursa (job #697457) | Cod sursa (job #3031482) | Cod sursa (job #333274)
Cod sursa(job #333274)
Program fact;
var f,g:text; np,p:longint;
procedure initiere;
begin
assign (f,'fact.in'); reset (f);
assign (g,'fact.out'); rewrite (g);
readln (f,p);
np:=0;
end;
procedure incheiere;
begin
close (f); close (g);
end;
function nc (x:longint):longint;
var y:longint;
begin
y:=0;
while (x mod 5)=0 do begin
y:=y+1;
x:=x div 5;
end;
nc:=y;
end;
procedure calcul;
var x:longint;
begin
if p=0 then begin
writeln (g,1);
close (f); close (g);
halt (0);
end;
x:=0;
repeat
x:=x+5;
np:=np+nc (x);
until np>=p;
if np=p then writeln (g,x) else writeln (g,-1);
end;
begin
initiere;
calcul;
incheiere;
end.