Pagini recente » Cod sursa (job #2059994) | Rating awd dfs (hatsumomo) | Cod sursa (job #1778403) | Cod sursa (job #2425770) | Cod sursa (job #359110)
Cod sursa(job #359110)
var p,n,i,x:longint;
function div5(x:longint):byte;
begin
if (x mod 5<>0) or (x=0) then div5:=0
else div5:=div5(x div 5)+1;
end;
begin
assign(input,'fact.in');reset(input);
assign(output,'fact.out');rewrite(output);
readln(p);
i:=0;
n:=0;
repeat
x:=1;
inc(i);
n:=n+x*5;
if i mod 5=0 then x:=div5(n);
p:=p-x;
until p<1;
if p<0 then write(-1)
else write(n);
close(input);close(output);
end.