Pagini recente » Cod sursa (job #163100) | Cod sursa (job #903088) | Cod sursa (job #2371055) | Cod sursa (job #2309082) | Cod sursa (job #45022)
Cod sursa(job #45022)
var n,p,max:int64;
f,g:text;
procedure fact(last,rest,s:int64);
begin
if s=p then begin
writeln(g,last*5);
close(f);
close(g);
halt(0);
end;
if s<p then begin
fact(last*5+rest,0,s+last*5+rest);
fact(last*5+rest,1,s+last*5+rest);
fact(last*5+rest,2,s+last*5+rest);
fact(last*5+rest,3,s+last*5+rest);
fact(last*5+rest,4,s+last*5+rest);
end;
end;
begin
assign(f,'fact.in');
assign(g,'fact.out');
reset(f);
rewrite(g);
read(f,p);
max:=-1;
if p<>0 then begin
fact(0,1,0);
fact(0,2,0);
fact(0,3,0);
fact(0,4,0);
end
else max:=1;
writeln(g,max);
close(f);
close(g);
end.