1.
program noi_003;
const n=7; m=6;
var i,j,x0,y0,x1,y1,x2,y2:integer;
d:real; p:boolean; g:array[0..n,0..m] of 0..1;
function disp(x1,y1,x2,y2:integer):real;
begin disp:=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); end;
begin
for i:=0 to n do for j:=0 to m do g[i,j]:=0 ;
readln(x1,y1,x2,y2); g[x1,y1]:=1; g[x2,y2]:=1; p:=true;
while p do
begin
p:=false; d:=disp(x1,y1,x2,y2); x0:=x1; y0:=y1;
for i:=4 to n do for j:=0 to m do
if (d>disp(i,j,x2,y2))and(g[i,j]=0)then
begin d:=disp(i,j,x2,y2); x0:=i; y0:=j; end;
if(x0<>x1) or (y0<>y1) then
begin x1:=x0; y1:=y0; p:=true; g[x1,y1]:=1; end;
d:=disp(x1,y1,x2,y2); x0:=x2; y0:=y2;
for i:=0 to 3 do for j:=0 to m do
if (d<disp(x1,y1,i,j)) and (g[i,j]=0) then
begin d:=disp(x1,y1,i,j); x0:=i; y0:=j end;
if(x0<>x2)or(y0<>y2) then
begin x2:=x0;y2:=y0;p:=true; g[x2,y2]:=1; end;
end; writeln(x1,y1,x2,y2)
end.
输入:7 6 0 0
输出:4302
2.
program noi_002;
var i,j,l,n,k,s,t:integer; b:array[1..10] of 0..9;
begin
readln(l,n); s:=l; k:=1; t:=l;
if n>l then begin
while s<n do
begin k:=k+1;t:=t*l;s:=s+t end;
s:=s-t;n:=n-s-1;
for i:=1 to 10 do b[i]:=0;
j:=11;
while n>0 do
begin j:=j-1; b[j]:=n mod l; n:=n div l end;
for i:=10-k+1 to 10 do write(chr(ord('A')+b[i]));
readln;
end
else writeln(chr(ord('A')+n-1))
end.
输出:BBAC