1.
program nbcz09_1;
var u:array[0..3]of integer;
a,b,c,x,y,z:integer;
begin
read(u[0],u[1],u[2],u[3]);
a:=u[0]+u[1]+u[2]+u[3]-5;
b:=u[0]*(u[1]-u[2]div u[3]+8);
c:=u[0]*u[1] div u[2]*u[3];
x:=(a+b+2)*3-u[(c+3)mod 4];
y:=(c*100-13)div a div(u[b mod 3]*5);
z:=(a+b+c-x-y)*2;
if((x+y)mod 2=0)then z:=(a+b+c+x+y)div 2;
writeln(x+y-z);
end.
输入2 5 7 4
输出:263
2.
program nbcz09_2;
var a,work:array[1..100] of integer;
i,j,x,d,max:integer;
begin
readln(max);
for i:=1 to max do begin
read(a[i]); work[i]:=a[i];
end;
d:=max div 2;
while d>=1 do begin
for i:=d+1 to max do begin
x:=work[i];
j:=i-d;
while (j>0) and (x<work[j]) do begin
work[j+d]:=work[j];
dec(j,d);
end;
work[j+d]:=x;
end;
d:=d div 2;
end;
for i:= max downto 1 do
if a[i]=work[i] then write('1')
else write('0');
writeln;
end.
输入8
71 88 149 32 66 90 144 99
输出:01000000
3.
program nbcz09_3;
var p:array[1..10000]of longint;
n,i,x:longint;
function find(x:longint):longint;
begin
if p[x]=x then find:=x
else begin
p[x]:=find(p[x]);
find:=p[x];
end;
end;
begin
readln(n,x);
for i:=1 to n do read(p[i]);
writeln(find(x));
for i:=1 to n-1 do write(p[i],' '); //两数之间输出一个空格
writeln(p[n]);
end.
输入5 5
3 3 3 2 4
输出:3
3 3 3 3 3
4.
program nbcz09_4;
var n,n1,p,q,d,e:longint;
i,x,y,s:longint;
function euclid(a,b:longint;var x,y:longint):longint;
var d1,x1,y1:longint;
begin
if b=0 then begin
x:=1;y:=0;d1:=a;
end else begin
d1:=euclid(b,a mod b,x1,y1);
x:=y1;y:=x1-a div b *y1;
end;
euclid:=d1;
end;
function MLE(a,b,n:longint):longint;
var i,d,x,y:longint;
begin
d:=euclid(a,n,x,y);
if b mod d=0 then MLE:=x
else begin writeln('Error!');halt;end;
end;
begin
readln(p,q,e);
n:=p*q;n1:=(p-1)*(q-1);
readln(x);
s:=1;
for i:=1 to e do s:=(s*x)mod n;
writeln(s);
d:=MLE(e,1,n1);
readln(x);
s:=1;
for i:=1 to d do s:=(s*x)mod n;
writeln(s);
end.
输入3 11 7
9
15
输出:9