Pagini recente » Cod sursa (job #2242586) | Cod sursa (job #1656973) | Cod sursa (job #2246159) | Cod sursa (job #272234) | Cod sursa (job #51918)
Cod sursa(job #51918)
var a,z,li,lf,w,p:longint;
//a,z:int64;
procedure cautare_bin(li,lf:longint);
var i:int64;
e:double;
begin
a:=((li+lf-1) div 2);
i:=1;
w:=0;
while trunc(a/i)>0 do
begin
i:=i*5;
e:=a/i;
w:=w+trunc(e);
end;
end;
procedure cautare;
var gasit:boolean;
begin
li:=1;
lf:=100000000;
gasit:=false;
while li<=lf do
begin
cautare_bin(li,lf);
if w=p then
begin
gasit:=true;
break;
end;
//else
if w<=p then
begin
li:=a-1;
end
else begin
lf:=a-1;
end;
end;
if not gasit then
a:=-1;
end;
procedure scriere;
begin
assign(output,'fact.out');
rewrite(output);
write(a);
close(output);
end;
procedure citire;
begin
assign(input,'fact.in');
reset(input);
read(p);
close(input);
end;
begin
citire;
cautare;
scriere;
end.