3)var ar:array of integer; s:string; oldnum,oldmd,i,j,m,bug,md,num:integer; begin; oldnum:=0; oldmd:=0; readln(m); str(m,s); setlength(ar,length(s)+1); for i:=1 to length(s) do val(s[i],ar[i],bug); for i:=0 to length(s) do begin; md:=ar[i]; num:=0; for j:=i+1 to length(s) do begin; if md=ar[j] then inc(num); if num>oldnum then begin; oldmd:=md; oldnum:=num; end; end; end; writeln('Result:',oldmd); end.
2)var n,m,i,d:integer; begin; readln(n); readln(m); for i:=1 to n-1 do if (n mod i=0) and (i<m) then d:=i; writeln('Result:',d); end.
Answers & Comments
Verified answer
3)var ar:array of integer;s:string;
oldnum,oldmd,i,j,m,bug,md,num:integer;
begin;
oldnum:=0;
oldmd:=0;
readln(m);
str(m,s);
setlength(ar,length(s)+1);
for i:=1 to length(s) do
val(s[i],ar[i],bug);
for i:=0 to length(s) do
begin;
md:=ar[i];
num:=0;
for j:=i+1 to length(s) do
begin;
if md=ar[j] then inc(num);
if num>oldnum then
begin;
oldmd:=md;
oldnum:=num;
end;
end;
end;
writeln('Result:',oldmd);
end.
2)var n,m,i,d:integer;
begin;
readln(n);
readln(m);
for i:=1 to n-1 do
if (n mod i=0) and (i<m) then d:=i;
writeln('Result:',d);
end.