Pagini recente » Cod sursa (job #1733396) | Cod sursa (job #2737614) | Cod sursa (job #2364376) | Cod sursa (job #2632747) | Cod sursa (job #29518)
Cod sursa(job #29518)
var f,g:text;
nat,x,p,a,b,c:longint;
ok:boolean;
function putere(m:longint):longint;
var put:longint;
begin
put:=0;
while m>0 do
begin
put:=put + m div 5;
m:=m div 5;
end;
putere:=put;
end;
begin
assign(f,'fact.in');reset(f);
assign(g,'fact.out');rewrite(g);
readln(f,p);
a:=1;
b:=1999999999;
ok:=false;
if p=0 then write(g,'1') else
if p=1 then write(g,'5') else
if p>=2 then
while a<b do
begin
c:=(a+b) div 2;
x:=putere(c);
if x=p then
begin
nat:=c - c mod 5;
writeln(g,nat);
a:=b+1;
ok:=true;
end;
if x<p then a:=c+1;
if x>p then b:=c-1;
end;
if (p>=2) and (ok=false) then writeln(g,-1);
close(f);
close(g);
end.