Pagini recente » Cod sursa (job #679519) | Istoria paginii utilizator/ghiurutan2001 | Statistici Alexandrescu Andrei (Andrei_Alwex124) | Istoria paginii runda/oni_2019_11-12_ziua2/clasament | Cod sursa (job #529066)
Cod sursa(job #529066)
var
n,p,k,i,x:longint;
procedure citire;
var f:text;
begin
assign(f,'factorial.in');
reset(f);
read(f,p);
close(f);
end;
procedure determinare;
var m,t,c,u:longint;
begin
n:=1;
repeat
if n=1 then
x:=0
else
begin
k:=0;
m:=0;
t:=0;
for i:=1 to n do
begin
if i mod 10<>0 then
c:=i mod 10
else
c:=0;
if c=2 then
inc(k);
if c=5 then
inc(m);
if c=0 then
inc(t);
end;
if (m>=k)and(m<>0)and(k<>0) then
x:=k+t;
if (k>=m)and(m<>0)and(k<>0) then
x:=m+t;
end;
inc(n);
until x=p;
end;
procedure afisare;
var g:text;
begin
assign(g,'factorial.out');
rewrite(g);
n:=n-n div 10;
write(g,n);
close(g);
end;
begin
citire;
determinare;
afisare;
end.