Вы находитесь на странице: 1из 282

&

. .


2003

32.973.3
519(075.8)+681.142.2

20
:
(. - , . . );
- , . .

. .
20

. : . /. . . .: , 2003.

288 .: .
ISBN 5-93208-093-0
. , . , .
,
- ,
-, ,
.
32.973.3
519(075.8)+681.142.2



.
.
.
22.04.01. 6090'/1.
. . .
. . . 18,0. 3000 . 2697

(095)955-0398. E-mail: lbz@aha.ru
066140 12 1998 .

.160001, . , . , 3.
ISBN 5-93208-093-0

. . , 2002
, 2003

6
1.
8
1.1.
8
1.2.
9
1.3.
9
1.4.
10
1.5.
11
1.6.
11
1.7.
12
1.8. ,
14
1.9.
15
1.10.
16
1.11.
18
1.12.
19
1.13.
20
1.14.
21
2.
24
2.1.
24
2.1.1.
24
2.1.2.
25
2.1.3.
26
2.2.
31
2.2.1.
32
2.2.2.
33
2.3.
37
3.
39
3.1.
39
3.1.1.
41
3.1.2.
41
3.1.3.
42
3.1.4.
42
3.1.5.
42
3.1.6.
43
3.1.7.
44
3.2.
49
3.3. . . . . 51
3.4.
53
3.5.
56
3.6.
59
3.6.1.
60
3.6.2.
.63


4.
4.1.
4.2.
4.3.
4.4.
4.5.
4.6.
4.7.
4.8.
5.
5.1.
5.2.
5.3.
5.4.
5.5.
5.6.
5.7.
. .
6.1.
6.2.
6.2.1.
6.2.2.
6.2.3.
6.2.4.
6.2.5.
6.3.
6.4.
6.5.
6.6.
6.7.
6.8.
6.8.1.

6.8.2.

6.9.
6.10.
6.11. ,
6.12. ,
6.13.
6.13.1.
6.13.2.
6.13.3.

66
66
68
71
76
79
80
83
89
91
92
93
94
95
102
104
106
110

114
114
.115
116
116
117
117
124
125
126
130
137
139
145
151
156
160
172
177
178
180
182


6.14.
6.14.1.
6.14.2.
6.14.3.

6.14.4.
6.14.5.

6.14.6.
6.15.
6.16. ,

7. .

185
185
186
186
189
189
190
194
196

197

7.1.
197
7.2.
198
7.3.
199
7.4. ()
203
7.5.
207
7.6.
208
7.7.
212
7.8.
217
7.9.
218
7.10.
223
7.10.1. , . . . 224
7.10.2.
224
7.10.3.
225

8.
8.1.
8.2.
8.3.
8.4.
8.5.
8.6.
8.7.
8.8.




,



.

227
227
228
228
232
233
234
234
238

240
281
285
286

, , ,
, ,
..
.
. , ,
.

, , , , .

,
, ,
, .
, , , . , .

. .
,
.
, .

D ,
.
,
, . .
.
. , . ,
, . ,
. , {, , , }.
| \.
. , ,
. . ,
.
= {(,)\ <=, } .
5 = { | v &} .
- { | & &} .
\ - { | &} .
0 .
U .
A =U\ = { | } .

1.1.
, \ =0,\\ =
\ = . I A u5 I = + .


, , , . ,
, ,
. , .
, , .
, .
, , , , .

, - . , ,
, , , .

, , . , ,
.

1.3.

. , b , & \jB
+ . Xi,X2,...,Xk j = 0, / *j. , , Xt -,\ Xj
,

1=1

1=1

1.2.
, | | = / \ \ = ,
\\ = -.
. b &B , (,) <=* \ = . , . Xl,X2,...,Xk
, \Xt \=nis / =!,.
.
''
. / 5 , KB N
3 .
. : S= {^, s2, s3, s4, s5}
, T={t{, t2, t3} KB N. (s, tj), /'= 1, 2, 3, 4, 5;'= 1, 2, 3. ,
S N,
|5'|=5-3=15.

1.3.
. 2,..., . k. , a 2 fl i fl 3 fl 3 fl 4 fl 3 a 2 fl i ~ "
8. k ( ). ,
,

10

. 1.

,
.
k . XbX2,...,Xk , 1 = 2 = ... - Xk = (
2,..., } . { xX2x...xXk. , :
k
\Xl xX2*...xXk\=n .
. .
. : 2 = 3=4=5 = {, 1,..., 9},
1 = {1, 2,..., 9}.
{ 2 3 , 5. , AI 2 3 \ 5 9-10-10-10-10 =90000.

1.4.
al,a2,...,an.
k? ,
.
, %.
.
1
. , , &- k + 1
. , :

% =n(n-\)...(n-k+l)=n\/(n-k}\. ,
\ = ( -!)...! ! = 1.
. 17 . , .
?
. 17 3 . ^ =17-16-15 = 4080.

1.6.

11

1.5.
k , ,
. ,
,
.
, . , =" =!.
= (, 2,...,) 1, 2,...,
=

*\

, -

1, 2,..., ;
1, 2,..., , - ; '- . , ,
,

. , (3,2,4,1)
(* 2 4 l J ' ( 4 3 l 2 ) ' ( 2 3 l 4 J

H -

'

.
8 , ?
. , . , =

( 1

8 ^

. -

, ,
. , /*8 = 8! 8 .

1.6.
,
, , . k
k, , -

1.

12

. * [ ?
\
. k. . ,
, , ..
k. *. ,
. ,
**!=4*.

* =

:,
k\

* = " ' ,
k\(n-k}\

Qk = Qn-k

1 2 3
.
2

3
, ?

. . + 1 . ^+1. 2+1 . ,

- +1.

1.7.
. . k, ?
,
Cnk = C^~lk_l =C*+k_l.
.
, ,,..., d ,
. cbbcaccda...ddaccbbb .
, : ... \ bb...b \ ... \... \ dd...d,
-

1.7.

13

, .
k + (n l) = n + k 1, k ; 1 . , + k 1 1
.
+LI . .
. 63 . ?
.
. . , , ,( = 3),
k = 63.
- , , .
. ,
/
363 = 3"63 =C32+63_1 =-^1 =2080.
.
*! +2 + ... + = k, k>0, xt> 0, /'= 1, 2,..., ; > I.
.
. xt= 1,+ 1,-+ ... + 1,
, {. 1,
(. , {11 12,..., !},
. , k (Ij, 12,..., !}. 1, , ;, . , ,

1 .

1.8. ,

. k . j
, 2 . ., nk &- ? , , =
{, , , , , , d, d, d, d}, 3 , 2 , 1 4 d.
, ,
. : = {3 - , 2 , 1 , 4 d}. ,
.
, al; 2, -$, blt 2, cl, dlt d2, d$, d$, 10! , . 3!-2!-1!-4!, 3! , 2! ,
, d 4! .
^ . , ( )

= J + 2 + ... + nk .
. . {
. "1 .
^ 2
, _ . , k-
C"nk_n _
_ . -

1 .9.

15

.
?
*
.

1.9.
S, | S \ = ,
k 5" = Si u S^ ... Sk, k

, \Sj\ = nh i= 1, 2,..., k ^], = .


Si, S2,..., Sk . Si,
S2,...,Sk Si ^1 , S2
"* . .,
Sk
- { - 2 -...- nk_i "*_ _ _ _ .
,
S k
\

Cnk

... v^
-rtj'
n-n1-...-nt_1

1 f

('

/ij, 2,..., /) .
1.
.
S= {1, 2,..., } Si, S2,..., Sk, Sj
'- . ,

.

1.

2. S Sl u S2 ... Sk = . | S \ = . , , Sj
& ( S{,
$2,..., Sk ): /ij Si,
^ . ., nk Sk,
{ + 2 + ... + nk = . ,
^...^,...^^^-^.
. , 25 ,
19
, 3, 3.
?
. : , , , 25 , 19 , 3 , 3 .
Cj5 -$ -] -jg^-y

1.10.

,
S, | S | = , , / = 1,
2,..., mt > / . ,

^/-/, =. :
7=1

7=1

7=1

i=lj=l

^ \$\ = \Sa \ = ... = | Sim. \ = / /' = 1, 2,..., .


. , , S- {1, 2, 3,
4, 5}

1.10.

V7

{1, 3}, {4}, {25};


{1, 3}, {25}, {4};
{25}, {1, 3}, {4};
{4}, {1, 3}, {25};
.
S
N(m^, m2,..., ). =l-ml +2-2 +...+-:
flf 1 !

/-<2
1

/-i2

<

/712

/">3

/^

'"

!2...(!)'""

ml + 2 +... + , /, /
.
. , ( ). .
/, .

.
, .
mt, /,! ,
. ml\m2\...ml^. , . ,
\
N(m,,m'>....,mn)=
'
,
(), .
, {0,1}.

IjB

1.

. 17
6 2 1 5 ?
. 17 .
17!
7V(Q 6 03,045,06,07,...,0 )=
.
6

(2!) (5!) 6!1!

. 36
, ?
. 4 11 = 3
(2!)22!

( ), .. 3
. ,
, 32
. 32 ,
, ^^. 16! 16!

1
41
32'
3-32

.
= _ . .

1.11.

nl+n2+...+nk=n"l -2 "*

...

..

,
j + 2 + ... + nk = , , > 0, / = 1, 2,..., k.

+xk)...(xl + x2+...+xk)=(xl
, k
jc"11 xn^j . . .x",

+ 2 + ... + nk = n.
x"lx^2 ...x"kk jct

1.12.

19

(xl + 2 + ... + xk)n.


1^ . { 2 2 .
"1 . . "1 "22 . . .x"kk
(xl+x2+...+xk)(xl + x2+...+xk)...(xl +x2+...+xk)
~"~
\
'^ ..."^_ _^ ^ =^
'^ , .

1.12.
(1.11.1):
= YJCkakbn'k

(1.12.1)

.
, .

1. ^* =2".
. (1.12.1) ,
= 1 = 1, (1+1)" =^% -lk -l"~k .

2. ^( -l)"'k =m".
*=
. (1.12.1), = 1
= 1.

*=1

3. X /? = Z

=2

. (1.12.1),
= 1 = -1, (1-1)" = (-!)* * =0. *=
,

20

1.

f
/t=0

2*

'.
/t=l

)t=0

*=1

* =2, -

/t=0

2".
4. ]^ k -* =2"~1.
. (1.12.1), , = 1 = , (1 + jc)" = "^Ckxk.
(l+x)""1 = ^k-Ckxk~l. = 1 ,
n(l+l)"~l = ^k-Cklk~l, .

1.13.
,
.
, ,
.
( 1 , 2 ,..., ) {1,
2,..., }. / <j, , > ,-, (a,-, aj)
. , 3142
(3, 1), (3, 2), (4, 2). , ; , ,
, (1,
2,..., ).
({ , 2 , . . . , ) d{d2...dn, dj , /
/ , dj ,
/ , 5 9 1 8 2 6 4 7 3 2 3 6 4 0 2 2 1 0 , 5 9
1; 5, 9, 8 2 . . 20 .

< dv < - 1, 0<d2<n-2, ..., < </_! < 1, dn = 0.

1.14.

21

. , . d"id2...dn , , ,
!,...,! ( ). , , (2,3,6,4,0,2,2,1,0) = d^d^d^d-jd^,
: 9;
ds = 1, 8 9. d1 = 2, 7 8
9. d6 = 2, 6 ; , 9,8,6,7.
5 , d5 = 0; 4
, 3 (. .
) 5,9,8,6,4,7,3.
2 1, (5,9,1,8,2,6,4,7,3).
, , , ,
. ,
, :
{1,2,...,}? , , d{
, d2 d{ - I .., dn . ( !)...! = \. , dj , uj .

1.14.
. 2,..., ,
. = (1, 2,..., ). = (^^.....^) 1, 2,..., , nk fc- .

. , ,..., . (. .1.5),
| 2 | .
1*1 "2 )

22

1.

, .
= (1; 2,..., ) = (CTI, 2,..., ) 1, 2,...,

= =
''
...
2
= , ,..., ), .. =!
2

, = =
'"

'-'

( 1

\ 1

".

,,

v jtj

"].
Pnj

api,api,...,apn pk =^
k- .
\ =( 1 2
71

V !

2 ' '

~' = '
"
-i -i
-i I ^ 1 2 ... ) [ji^ 2 ... j
, ,
, .. "1 =(itll,n21,..., ~'). ,
= (^ 2,...,
) '1 = (^1, 2!,..., '1) ,
..

2 '.'.'.
(5,9,1,8,2,6,4,7,3) (3,5,9,7,
59 1
1 6 8 4 9 ^ ^
8 2 6 4 7 3 W 1 2 3 4 5 6 7 8 9')
1,,/4>, , |1 2 3 4 5 6 7 8 9j~ v 3 5 9 7 1 6 8 4 2J
= (1, 2,..., ) , elt <?2,...,
enfar k =l to n do en =nk f{nk] = nk.

1.14.

23

, q, e2,..., 1,2,...,. uk (. .5.7). 1


:
1
' =(^', 2 ,..., " ),
1

" nk
= ( 2,..., ):
1

for k=\to n do " = k n' [nk]=k.


1

' =(^, ^ ,..., " )


= (KI, 2,..., ).
X. . :
, .

,
, , .
,
, , . ,
, , ,
, . , : , , . .

2.1.
,
,
, .

2.1.1.
. 5 s2, ..., sn , . ,
. . . . -

2.1.

25

, .
Sj si+i s^, S/+2,..., sn
; ^ , 2.1.
2.1.

( z i-e }
= + 1;
forj - 1 to i by 1 do Sj+i = Sj,
st = z.
{ i- }
forj = i to n I do Sj = Sj+l'}
n = n 1.
.

-
0().

2.1.2.
, sk ,sk ,...,sk
5j, s2,..., sn. , , /'- , Sj .
, (1,2,3,4,5,6,7,8,9) , 3,
(0,0,1,0,0,1,0,0,1).
,
, . ,
.

2.

26

2.1.3.

,
, .
.

, , . . sb
s2,..., sn Sj /,,
si+l, li+l no
. /0,
s^ . /
, .
:
. DATA ,
NEXT .
. ,
NEXT(/i) = NEXT(/2).
:


sr
sl} : NEXT(/r) = NEXT(/j)
NEXT(/j) = lr, . :

2.1.

do

27

/0 H



, , / st. , . , ,
,
. 2.2 2.3 , Pascal , .
: ,
.
. , , , .

.

. 2.1.

,
,
.
. ,

28

2.

,
.
. 2.2

/"*

5,

1*2

2.2. Pascal '



Program Number_List; { }
uses CRT;
type
NodePointer=ANode;
Node= RECORD
{ }
s
:Integer; ( }
next :NodePointer;
{ }
END;
const first :NodePointer=NIL;
{ }
{ }
function InitNode: NodePointer;
var newNode :NodePointer;
begin
New(newNode);
{ }
newNodeA.s:=Random(99)+1;
{ }
newNodeA.next:=NIL;
InitNode:=newNode;
end;
{ }
procedure IncludeNode( newNode: NodePointer );
begin
newNodeA.next:=first;
first:=newNode;
end;
{ k- }

2.1.

procedure DeleteNode ( k : Integer ) ;


var previos, current :NodePointer;
i : Integer;
begin
i : =0 ;
current : =f irst;
while currentoNIL do begin
if i=k then begin { k- }
if f irst=current then f irst :=currentA .next
else previos'4 .next : =currentA .next;
{ }
dispose (current) ;
break;
end;
previos : =current ;
current : =cur rentA . next ;
end;
end;
procedure PrintNodeList; { }
var p :NodePointer;
begin
WriteLn;
p:=f irst;
while ponil do begin
Write (pA.s:3, ' ') ;
:= .next
end;
end;
Var {Main} i,m,n : Integer;
begin {Main}
ClrScr;
Randomize;
n:=17; { )
for i:=l to n do IncludeNode (InitNode) ;
PrintNodeList;
WriteLn;
m:=17; { m- }
DeleteNode (m) ;
PrintNodeList;
ReadKey;
end. (Main)

29

30

2.

2.3.

#include <stdio.h>
tinclude <stdlib.h>
ttinclude <conio.h>
typedef struct tagNode{ //
int s; //
tagNode *next; //
//
}Node;
typedef Node *NodePointer;
Node *first;=NULL; //
NodePointer InitNode( void )( //
//
NodePointer newNode;
newNode=new Node; //
//
newNode->s=random(99) + 1; //
//
newNode->next=NULL;
return newNode;
}
//
void IncludeNode ( NodePointer newNode ) {
newNode->next=f irst;
f irst=newNode;
}
void DeleteNode ( int k ) { //
//k-
NodePointer previos, current;
int i;
i=0;
current=first;
while ( current !=NULL ){
if ( i==k ) { //k-
i f ( first==current ) first=current->next;
else previos->next=current->next; //
//
delete current;
break;

2.2.

31

previos=current ;
current=current->next ;
void PrintNodeList ( void ){ //
//
NodePointer p;
p=first;
while ( p!=NULL ) {
printf ("%3d ",p->s) ;
p=p->next;
void main ( void ) {
int i,m, n;
clrscr { ) ;
randomize () ;
n=17; //
for( i=0; i<n; i++ ) IncludeNode ( InitNode ( )
PrintNodeList () ;
printf ("\n") ;
m=17; // m-
DeleteNode (m) ;
PrintNodeList () ;
getch() ;
, .

2.2.
^ , , , ,
> 0 7\, 2,..., .
. 2.3 9 ,
e,f, , g, h, r ,
. . . , .

2.

32

. 2.3.


. , , , : 7i 2.
. , ,
, ,
.

2.2..


.
. .

first

. 2.4.

,
, , .

2.2.

33

first

. 2.5.


, .
;
; ,
, (
).

2.2.2.

(
) ,
. .
,
( ).
() .

2,..., .
. 2.6.
. 2.6 .
a[k] ,
k ( ) 1
( ). [] , m
. , .
22697

34

2.

a[2k]

a[2k+l]

a[m] . . . a[n]

. 2.6.

, , . ,, ,..., ,. , = [_(/ +/)/2_|, .. . ,, /+1,..., _\,


+1, +2,..., ,. , . . , , ..

.
.

/ 15
abc. 1.
.
.
. ,,
. +1
, .
:
4

2.2.

35

:
abcba
ababa
acaba
abaca

acbca

1
2
3
4
5
6

2.4
. . ( CreateTreeA.bc) . 2.7.
2.4. Pascal's

Program _; { )
uses CRT,DOS;
const n_max=$fcOO; { }
type
var f
z

Vector=array[1..n_max] of Char;

:Text; { }
:Vector; {
}
Procedure CreateTreeAbc( n:Integer ) ;
{ }
var
k,level,m,ml,m2 :LongInt;
begin
z[l]:='a'; { }
level:=1; { }
ml:=l; { }
m2:=l; { }
while level<=n do begin
for k:=ml to m2 do begin {
}
m:=2*k;
case z[k] of
'a': begin z[m]:='b'; z[m+l]:='c'; end;
'b': begin z[m]:='c'; z[m+l]:='a'; end;
'c': begin z[m]:='a'; z[m+1]:='b'; end;
end;
end;
level:=level+l;

36

2.

ml:=2*ml;
m2:=2*m2+l;
end;
end;
Procedure RouteTreeAbc( n:Integer ); {
}
var
i,k,ml,m2,r :LongInt;
begin
r:=0; { }
k:=l;
for i:=l to n do k:-2*k;
ml:=k;{ }
m2:=2*k-l; {
}
for i:=ml to m2 do begin{
}
k:=i;
if z[k]='a' then begin
r:=r+l;
WriteLn(f);
repeat
Write(f,z[k]>;
k:=k div 2;
until k=0;
Write(f,' \ r);
end;
end;
end;
Var (Main) n :Integer; { }
begin (Main)
Assign(f,'treeabc.in');
Reset (f); { }
Read(f,n); { }
Close(f);
Assign(f,'treeabc.out');
Rewrite(f); { }
CreateTreeAbc(n); { Abe
}
RouteTreeAbc(n); {
}
Close(f);
end. {Main}

2.3.

37

, ,
,
. , ,
. , ,
. . 2.7
( ).

[4]

[8]

[5]

b[9]

b[10]

c[ll]

[6]

b[121

[13]

[7]

[14]

[15]

/\ /\ / \ /\

[1| [17] [18][19] [20] [21] [22] [23] [24] [25] [26] b[27] a[28] b[29] b[30] [31]
. 2.7.

( RouteTreeAbc), . 2.7. ,
. ,
( ) .

2.3.

.
1. ,
, , .
2. ,
, .

2.

38


,
(. 2.8).
. 2.1 .

\ -

#
. 2.8.
,
, . :
, ;
; ; ,
. , .

. U (. .
),
. 5{/ . / 1 , /- U S, 0 (. 2.9).
,
/-
, . , , v . ,
, U, S.
, ( U) .
X

1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 0
. 2.9.



,
. . ,
, ,

. , .

3.1.
0, j, 2,... . :
4*) = !>***
(3.1.1)
*
() 0, ai,a2,.... , () (3.1.1) .
, {ak}
(). (3.1.1) () = 0.
.

40

3.

()
1
v 1-*
1-
&i

(1-)

1-*
1 ,

^,t(l f +, \ 1)\v-A

- 1 *
V

,(;>'
i *

(i + *)'

-I

"

=Z

"

1
v-xY

/t

'

..*
r
-xk

(r+ k -iV*
*
J*

^,1
~h

at

{^}

"'

(3.1.3)

k+l, k>0

. at

(3.1.4)

^ '

' *

'

'

at = l^},k>l,r
|4 = ,2:0

(3.1.6)
(3.1.7)

i at = , > 0 , /-
at

'

+-
^
\,>0,

(3.1.8)

(3.1.9)

. ^- - .
. ak - - , 0 < k < .

{ak} () = ^akx .

() . , 0() = 1,
AI(X) = 2 + , 2() = 4 + 4 + 2. +1() {ak} ( +1)- . , ( +1)- -
( +1)- .
( ). , ( +1)- - ^-
(k +1)- . ,
+1() = 2() + (), ^) = 1.

3.1.

41

:
k=0

4=0

x , ,
k k
:- - ak = 2"~ C t . ,
3

3 1

3 2

)=2 - +2 - 3-; +2 - C 3 JC +2 - C3V = 8 + Ux+ 6x +


+ x\
(3.1.2) (3.1.9) .
, ..
. {ak}, {bk}, {ck} ,
(;), (), ().

3.1.1.
, ck = a ak + p bk
() = . () + (3 ().
, {1} - , \ L 1-
[^!j
*, \ 100 + I 100 .
- +5 .
1-

k\\

3.1.2.
{bk} {ak} :
bk = Q k = 0, 1,..., / - 1
bk = ak_j k = i, i + 1 ,..., () = '().

k=i

42

3.

3.1.3.
{bk} {ak} : bk = ak+i, k = 0, I,...,
*=0

=0

/-I

/-I

.*=0

k=0

A=0

3.1.4.
{bk} {ak} :
bk =Z u i> k = . !>> ()=-^-.
/=
1-*

*=0 U0

(k, /),
, . ( /,
k). ()

1234

/t=o /=o

/=o

/=o

3.1.5.
{bk} {ak} :
** =|>/. * = 0. 1..... () =(1)~
i=k

1-

3.1.

43

;uo

*=oV/=*

(k, f),
, . ( /,
). ()

u=o

1=0

(=0

'

1 2 3 4 k
,/+1

^ /=
(\)--()
v

3.1.6.
1. {bk} {ak} :
bk = k- ak, () = '().

-1

*=

=B(x).
2. {bk} {ak} :
=p-,
k+1

B(x)=--\A(x)dx.
J

=0

K+i

k=0

k=0

44

3.

3.1.7.

k = -,' = - 1>->
/=

= *

00

00

, ) = ^*** 5() = ^^*,

/1=0

1=0

*=OU=0

00

A=i

Vi0

/=OA=i

)
\ I

00

00

) U=0

.
. .

-*)

k\
=

(_\\ ' V - - - "- ~1) _/'_1*

= .

3.1.

, (

45

22*-iM-3-5.7...(2*-3)
* - i - - . . . . -

^ 1..5..
. . . . ..(2*-3)
- t=

2*!
,
*
2**!
il-2-3-4-S-6...(2-3)(2fc-2) =
fci

^l-2-3-4-5-6...(2fc-3)(2fc-2)
>

J^

1 ~2_,
*

2**!-2-4-6...(2-2)

Z.

\Lil\,

_~~

x =1-2^^-=-x .

2* I.

4L

* Vx I.

fc

,
,2 A-l

=(!-*)

/= 1.

, =(l-jc)-1 =(-!)* (-)* =Jjc


1-:

.
( + 3) - ( > 0) , ?
. +3
( + 3)- . 1 + 3. ,
, + 2 + 3. 1,2,...,+1.
k. + 2,
+ 3, k, k + 1

46

3.

+ 3 k, +1 un+3_k
. k = 1, 2,..., + 1, ( )
( + 3)- :
+3 = 2 ' "+2 + "3 ' +1 + 4 ' "- + - "+1 ' 3 + +2 ' "2.

> 0 2 = 1.
{+2}, > , {vn}, > 0, , vn = +2, >0.

V n+ l = ' V/I+0 + VI _! + V 2 ' V n _ 2 + ... V n _! ' V t + V n _ 0 ' V 0 ,

k=0

,
{vn} {vn} (. .3.1.7 ). ,
=0

n=OU=0

() {vn},
> 0,

V\x) - V(x) + 1 = 0.


-1 2 '^-2
^l
k

3.1.

_ 47

V(x) *, V(x) =(1/ 2x)(l + Vl-4x) .

"
+2 =vn =-^- , > 0.

: ( + 2) -
"
^- , > 0.
+1
/f
2
2
2
2
. ! +2 +...+ k = ^' .
i=i

:

ak = l,bk = kak, ck = kbk, dk = / 2 (), B(x), C(x), D(x).


/=o
dk. D(x), dk,
00

) = ^dkx . bk ak
*=
, () = '(). ck bk , ,
() =-'()=(-'() =-'()+2"().
dk ck ,
2
D(x) = C(x)=x-A'(x)+x A"(x)
1-
1-

D(x) = - 4/ .
(1-^)
dk
(3.1.9):
1

48

3.

k=0

k=2

k=0

:,
3
d0=0, dl=Cl, dk=C k+l+Cl+2, =2,3,....
,
2

I +2 +...+k = ]/ =Cl+\ +%+2 ~


/=o

. , 2^C'r+i =C*+k^

, -

- = ^+;*

ak =CkrJfk. , k

^C'r+i =^, .
;=0

1=0

. =] .. /^
()
1

L J
D/
, ( ) = - - -= -2 z- .
1-Jc (1-jc)"
(3.1.9)
:
-)

k=o

1=0

1=0

. . 7
. (. .) X

k=0

A=0

3.2.

49

, gj^s) (= k), k= , 1,... . (. .). . .


Z=X+ Y. ,

P(Z =k) = P(X + Y=k) = Y,P(X = i)P(Y =k -/).


i=0

.. Z :
k)s
k=0

=gx(s)gY(s).

3.2.
{}, = , 1, 2,... . , , {}
+ =1+-1 + 2 + -2 ++,->

(3-2.1)

cl, 2,..., . (3.2.1) /-. , , MO, HI,..., _


. (..
) (3.2.1).

= 1>***
(3-2.2)
*=
{}.
() = 1 2* ... c^f

) = ().
, ()
, 1, +
" ( = , 1,...) U(x)K(x),
(3.2.1), un+r- (qH^-i + c2un+r_2 +... + ^) = 0 .

50

3.

(3.2.1)
F(x)=xr -Clxr'1 -c2xr-2-...-cr_lX-cr.

(3.2.3)

)
=(* -, )<>(*- 2 2 -(*-,-)'',
! + 2 + ... + =.
() F(x), () =xrF\ - I

U/

ei

e2

= (l-alx) (l-a2x) ...(l-arxY , el + e2

= .

:
/<*)= - = -
()
kk(\-aiXy

(3-2.4)

, )
(1-)"
(3.2.4)
() _ ^

Y'/'/j+-ji t
'
'

>=-=2-2-*|-2-1

/=1=1

.. 9 -,

A=0


00

U(x) = ^," {}. =0

(3.2.5).
. {}, +2 = 5+1 6, = ^ = 1.
. () = 1 - 5 + 2, K(x)U(x) = ().

3.3.

51^

: (1 5 + 6 )(0 + + z^x + ...) =


2
= 0 + (! 50) + (2 5! + 62) +... = HO + (MJ -50) = 1 4.
, () = 1 4.
2
) = 5 + 6 = ( 2)( 3).
/()=

=
+ _ _ . (1-2)(1-) 1-2 1-
:
= 2, = 1. , (3.1.2),

, U(x) = ^ukx . , =0

+1

", , = 2" 3".

3.3.

+/ =clun+r-l +2+/-2+"-+" +,

(3.3.1)

.
(3.3.1)
(3.3.1) (.. ,
)
(3.2.1), .
,
.
,
(3.3.1).
. {}, , +1 = + ( + 1)
0 =1.

",

52

3.


=0

=0

=0

(1-)

, 0 = 1,
-

V, ,

. ABC.
. .
. : ;
\
.
, = .
, , :
bn+i=an+bn,
C

n+l=an+Cn,

= .

= ( = , 1, 2,...)
,+1 = +V

3.4.

53

, {}. ,
= :
+2 = "+1 + 2, 0 =!,! = , = , 1, 2,... .

.
2
() = \--2 , U(x)K(x) = () = 1 -.

F(x) = 2 - - 2 = ( - 2)( + 1).
)=

*"*
= -JjL+ -Ji-.
(l-2jc)(l + jc) \-2 l + jc

U(x) :

00

00

Jn=0

^/1=0

n=0

=+2"*"+];(-1)''*"=2 V

V=xXn=0

", , 2" +(-!)" 2


=
-.

3.4.
51!, ^2,..., Sn .
Q = {(!, 2 , >>---} ~~ , ,
1, , , z, x~l, y~l, z~l . , ,
.
j &Sj(i= 1,2,..., ) (s) e Q. , . m(s) = 1.
, 5, , A(Sj) = ^Cfoco 51,.


S = SixS2x...*Sn ={E=(sls2...sn)\si eSj,i=l,n}.

3.

54


() = (

(=1

5, )eQ.

S ,
A(S) = ^. .

. A(S) = A(Si)A(S2)...A(Sn).
.

.
2
<^

.
1- ._1
AQ .
~\
.

0.
. 1
, 2 07, 3 OZ.
S^ S2,..., S2n ,
Si = S2 = ... = S2n = {I, 2, 3}. 2 S- S^ x S2 x ... S2n. , 2113
, AQ 5, $, 5 2.
: ( 1 ) = , ( 2 ) = ,
(3) = z.
2 A(S) = A(Sl)A(S2)..^A(Sn) = (x + + z)2n,
.. A(S,) = x + + z
,

. yJZ ,

k X

(3.4.1)

3.4.

55

/ , / OX, j
k OZ(i +j + k = 2), aijk ^*, , AQ,
x'y'z i,j, k, . . , , . = 1 = 2 = 1 (, , . ). (3.4.1)
( + + )2 = 0 + Cjyz + C^xz + Cgxy,
(3.4.2)
0 , ^; 2 2, 4
Aj, 6 6.
2, $, $ AQ, , 2 = 4 = 6 = . (3.4.2) ,

(3.4.3)
(3.4.3) 0
2 = 1 = z2 = 1.
(3.4.3), x = y = z=\ = -\, z=l.
, .. 2 = 2 = z2 = 1.

2 = 0 +

UCo-C
2
" +3
0 =
--

. , q
2 + 3q = , , , q e{0, 1, 2,...}.
. : Sl = {2 \ = 0, 1, 2,...}, S2 = {3<7 1 q =
= , 1, 2,...} S= Sl x S2 = {(2p,3q) \p,q = Q,l, 2,...}.
:
)(2^)=2^,(3^)=
() = ((2, 3q)) = 2^3^" = 2 3" = (2)(3).
,
A(S) =A(S{)-A(S2). , 2**3^" = (2, 3q) s5
2 + 3q = .

56

3.

A(S) = A(S\)-A(S2):
2

HO + i* + * + + "*" + =
20

2 1

2 2

= ( ' + ' + '

+
2

30

3 1

3 2

... + '" + ...)( ' + ' + ' + ... + '" + ...) =


4

= (1 + + +...)(1+ + +...)= -,
2
3
1- 1-
2 + = . , A(S) S
2 + = . ,
A(S) = - ^ -- :

(1-)

1-

7
1-3

*=0

k=0

k=0

2 + q = .
, -

:
_3-(-1) 3 "+2-(

~ ~

_3-(-1) 3 + 2 +2-(+3)+3_2+3 + (-1)3"

"12~

"4~

{0, 1, 2...}.

3.5.
S = {$!, ^2, ^"-"} ~ .
Q = {1,)2. ,...} , Q(JA) sk eS.
PI, 2, ,...,
.

3.5.

(
'

57

_ J 1>
k /> ,
[, sk PJ .

W(Pj )= ]] /5 (. ) (. fc ) -
skeS

W(Pt Pi2 ...Pim ) S,


Pt ,Pt ,..., Pim .
W(m) = ^W(Pj Pi2...Pim),
(Ifa-im)

(/1/20 ,
.
, W(m) , . s k nk>m, (,) ) .
, W(\) = 'YJW(Pi ) = W(Pi) + W(P2)+...+W(Pn) \ =

= 2)= ^W^P^W^PJ+W^P^ +...+ _1)


Cl'2)

2 =( + 1)/2 .
W(m) = 0,
^K(J) S.
6 W(Q) ,
) ,
. , .
:
() , ;
) ,
.
. , PI, 2,.~, >

() = "f(-l)' (% +/).
(3.5.1)
/=
. ,
e>(s) s e S

58

3.

(3.5.1) . ,? 6.5* /.
/ :
1) / < , co(s) () + /)
/ = , 1,..., . (3.5.1) 0 = 0.
2) / = , e>(s) () W(m).
3) / > , (s) () 0. , (3.5.1)
.
(s) + i) ,+' , + i < /.
(s) s
t-m

=)(-1)'+1..
/=0

,
m+i (w+Q!
*\
!/! ( +/)!(/-(+'))!

/!

(t-m)\

, +|+( =,,'_,
t-m

t-m
1=0

j=0

(3.5.1) . .
.

(0) = ) - W(l) + 2) - ) + ... +(-\)"W(n).


. 23 . 18
, 9 6 .
? ?
. S , \S \ = 23. co(j) = 1 s s S.
.
s e S:
PI , 2 .
) , ( ).

3.6.

__

59

) = W(0) - W(\) + W(2).


seS

1) = {) + W(P2) = 18 + 9 = 27.

2) = W(P,P2) = 6.
) = 23 - 27 + 6 = 2.
( 1) (
).
. ,
.
. . , , ,
/- , / = 1, 2...,
. () , , .. . :
() =

(-!)' ;+/ + i). W(r) = ^^ Ph ...Pir ),


1=0

(l 1 '2---'V)

(/j/j.-./V)
, .
W(Pt Pi:i...Pir)=(m -r)! , .

W(r)=Crm(m-r)l , (/)= ^(-l)1 ? (- -/)!


(=0

! , to '!

3.6.


.
, , .

3.

60

3.6.1.
.
, . . 3.1.
. 3.1
. . : rk ,
; 0 = 1
, ..
. . {rk}
00

IV v /" X" * k
\,{,) = 2_,rk v
'

(i (. \\
(j.O.JJ

. Q
. 3.2.
. 3.2
.
, 0 = 1, ^ = 1 /-, = 0, /' > 2. R(x, Cj) = 1 + .

. 2
. 3.3.
.
, 0 = 1, { = 2, 2 = 1 rt, = 0, / > 3.
. 3
. 3.4.
. 3.4
.
, 0 = 1, , = 3, 2 = 1 ,- = 0, /' > 3.
2
R(x, 3) = 1 + 3jc + .
. Q 2 - ,,
. . 3.5.

3.6.

61


1. . R(x, Q) R(x, C2)
Cj 2.
= Ci u 2, R(x, ) = R(x, CJRix, C2).
. \,
2 2. = (, 2) = \ 2. . Sn
52 , Q
2. 5 =Sn 2 .
: w^ ) =xkl , &,
; (2 ) = xk2 , k2 2.
s(n)=xkl+k2 =xki -* 2 = , )(2 ).
, , :
R(x,Cl) = ^(^lR(x,C2)= (* 2 ) (,)=().
(, Q), 7?(, 2) /?(, ) (. . 3.4), R(x, ) = R(x, C])R(x, C2).
. . 3.6.
Cj ,
R(x, \) = 1 + . ,
Q. ,
2. .
. 3.6
. :
, (/ index); Ce^ ( erase).
(,)=(>1)+(, ) R(xia + ) =(/ )+R(ea ).
.
Sn. S,e , Sn. ; 5 ,

62

3.

^,
.
. R(x, ) . 3.7.

. ,
3

b3& . '

3 7

" '

,
( ) ,
4.
3 .
, ; (. 3.8).
k : &!
.

k k
- 3.8
k
C^C . rk = %% -k\ k . R(x, ) =
min(/7i/i)

= CkmCkk\xk.
k=0

. R(x, )
2x3.
.
f^lf~>l-II...I ./^2f^2^iv2 _
^2^3 * +1'2^3 ^'*

2 ,
6.

3.6.

63

3.6.2.
.

(. 3.9). En(k)
, k
.

E(t) = ^\En(k)t

. 3.9

(()}.

. :
Sn = {1; 2,..., !} ;
= {!, 0)2,.-} ;
: Sn -> , () fi Sni
{1, 2,..., ) ;
PI, 2,..., ; Sn
PJ, /
( \-\ PJ,
J
\ , .
W(Pj) = ^ PJ ()() PJ,
W(PJiP**.".Ph ) = Z P A W 2 - ()()

,- Pj2...PJt;
W(k)=
//

\ /
^_,
v 7| Ji...: J ),
"
J
k

(/i/2) k , *.

,
() = 1. , ) = rk(n - K)\,
rk .
(k) = Ckkrk ( -k)l -Ckk+lrk+l ( -k + 1)!+. . .+(-1)"-* Ckmrm (n-m)\.

64

3.

, rk = 0 k > . , < ,
rk = k > .
k
k
Ett(k) = C krk (n -k)\ -C k+lrk+l ( -k +1)!+.. .+(-!)"-* > ( -)!

.() = J] (-1) C'k+irk+i(n-(k + i))l. (=0


*=0

=0/=0

. 3.10. k'= k + i /"= /

E(t) = ^^(-l)'C'krk(n-k)\t

k=0i=0


. 3.11. ,
= ^/-J (-!)'-?*~' (-)!
*= U=o
J

. 3.11

*=0


~ , : ~!()) =f(n - 1) ~*()) = - k).
, "1(!) = ( - 1)! ~*(!) = ( - k)\ .
, [(t- l)^lfnl = (t- l)V*7z! = (t- \)k(n-k)\.
k=0

k=0

=o
~,\

x = (t-l)E . , E(f) = R((t -

3.6.

.
3 3 . 3.12. .
. , .
R(x) = R(S> () = (1 + *)(! + + 2) = 1

65

. 3.12

42

= R((t- 1)E-V = (1 + 4(- De'1 + 4[(r- De'1]2


1 3
= 1 3! + Aft - l)s~l 3! + 4[(/- l^"1]2 3! + [(t- l)s~ ] 3! =
2

= 3! + 4(t - 1)2! + 4(f - I) 1! + (t - I) 0! .


2

, E(t) = l + 3t+t + t .
E(t) / , , ,
1 ( f );
3 ( t1)',
1 (
t2);
1 ( / ).

32697

= 4



. , ,
. ,
; . , ,

jq,
2,..., , .
, .. , .

4.1.
,
..., ..., ...,
. . ,

.
: -

4.1.

.
,
.

:

67

;
,
, .
,
, , ,
. :
,
, ,
,
.

,
( 2, $,...) , ,
. ai At,
AJ . , ( 2, 3,..., ,) , 2 ... Af, / = , 1, 2,...
.
()
, AI oj. S^ {.
({).
( a2,..., a A _i) ( 2,...,
ak_i, ak) ak Sk Ak. ( 2,..., ak_{) ak, Sk = 0; _!. ^ , ak_2 ..

68

4.

.
4.1.
4.1.
6*! =Ai', { }
k= 1; { }
while k > 0 do begin
while Sk 0 do begin
ak e Sk; { }
Sk = Sk {ak}; { }
if(ai, a2,..., ak) then ;
k = k+ 1; ( }
Sk Ak; { ]
end;
k = k 1; {, ]
end.
, ,
,

Y[\ Ak\ . , Ak \ = k=\

, ]^[|^|=.
*=i
,
.
, . , , , . ( ) , .

4.2.
{1; a2,..., }
.
, 1 , .. 1, 2,..., .

4.2.

69

4.2. ,
4.1 Sk. Sk, .. sk, .
Sk 0 sk < n,
, sk
. sk >
Sk = 0.
4.2.

SY = 1; { }
k = 1; { }
while k > 0 do begin
while sk<n do begin
ak = sk; { }
sk = sk+ 1; { }
while sk<n and notflag(sk) do sk = sk + 1;
ifk= n then ( 2,..., ) ;
else begin
k = k + 1; { }
s

k = i;

while sk<n and notflag(sk) do sk = sk+ 1;


end;
end;
k = k - 1; {, }
end;
Function flag(sk) { ske (1,2,---, ^_i)}
flag= TRUE;

/=i;

while i < k and flag do begin


if a, = sk then flag = FALSE;
i= i+ 1;
end.

70

4.

Pascal 4.3.
, ()
.
,
.
4.3. Pascal'

Program Start_BackTrack; { }
uses CRT,DOS;
Const max_n=20;
Type Vector=array[I..max_n] of Longlnt;
Function Flag(Var a:Vector; sk:Longlnt;
k:Integer): Boolean;
( sk [1],a[2],...,a[k-1] }
Var i
:Integer;
yes :Boolean;
begin;
yes:=TRUE; i:=l;
while (i<k) and yes do begin
if a[i]=sk then yes:=FALSE;
i:=i+l;
end;
Flag:=yes;
end;{Flag}
Procedure BackTrack (var f:Text; Var a:Vector; n:Integer);
{ [1],a[2],.. .,a[n] }
Const m :LongInt=0; { }
Var
s
:Vector; i,k :Integer;
begin;
for i:=l to n do s[i]:=0;;
s[!]:=!; k:=l;
while k>0 do begin
while s[k]<=n do begin
a[k]:=s[k];
repeat { a[k]}
s[k]:=s[k]+l;
until (s[k]>n) or Flag(a,s[k],k);
if k=n then begin { }
m:=m+l;

4.3.

71

Write(f,m,') ');
for i:=l to n do Write(f,a[i],' '); WriteLn(f);
end
else 1{ a[k+l]}
k:=k+l;
s[k]:=1;
while (s[k]<=n) and Not Flag(a,s[k],k) do
s[k]:=s[k]+l;
end;
end;
k:=k-l;
end;
end;{BackTrack}
Var (Main)
a :Vector;
n :Integer;
f .-Text; ( }
Hour,Minute,Second,SeclOO,rHour,rMinute,rSecond,
rSeclOO :Word;
delta :LongInt;
begin{Main}
Assign(f,'BkTrack.in' ) ;
Reset(f);{ }
ReadLn(f,n);{ }
Close(f);
Assignff,'BkTrack.out');
Rewrite(f); { }
GetTime(Hour,Minute, Second,SeclOO);
BackTrack (f,a,n);
GetTime(rHour,rMinute, rSecond, rSeclOO);
delta:=rHour-Hour; delta:=delta*60+rMinute-Minute;
delta:=delta*60+rSecond-Second;
delta:=delta*100+rSeclOO-SeclOO;
WriteLn(f,' =',delta div 100,'.',
delta mod 100,' ');
Close(f);
end{Main}.

4.3.

! {1, 2,..., },
,
, , -

72

4.

, . ,
.
. = 1 {1} . ,

1; 2> >--- {1, 2,..., },


. ( 1)! , .
:
1234
,123
23 1243
1423
[4123
4132
i \ 1432
17 13/
iH
11342
[1324
3124
3
1 2 3142
312
3412
[4312
4321
,13421
32
M 3241
[3214
2314
9,1 12341
21- 23
2431
[4231
4213
]
2413
213
21
12143
[2134

,
. : = (nl,
2,..., ), = (, 2,---, )
dt, / (1,
; +1, ; 0, ).

4.3.

73

, , , ; . ,
. , , . 4.4 .
. \ ,
\ + (\). 4.4 .
Pascal
4.5.
4.6 , .
4.4.
fori=\ ton
0 = nn+i = = n + 1; { }
Print = (1,2,...,);

=;

while \ do while . > do\

"!

[ =-1

: +dm ; ( }
.

<*\ ( =

,np,dm =m]

4.5. Pascal'

Program Start_Effeet; {
}
uses CRT,DOS;
Const max_n=20; { n<=max_n }
Type Vector=array [0. .max^_n+l] of Integer;
Var f :Text;
{ z[l], z[2], .../ z[n] }

74

4.

Procedure Effect( Var z:Vector; n:Integer );


Const k :LongInt=0; { }
Var
p,d
:Vector;
pm,dm,zpm :Integer;
i,m,w
:Integer;:
begin;
for i:=l to n do begin z[i]:=i; p[i]:=i; d[i]:=-l; end;
d[l]:=0;
m:=n+l;
z [0 ]:=m; z[n+1]:=m;
while mol do begin
{ }
k:=k+l; Write(f,k,') ');
for i:=l to n do Write(f,z[i],' '); WriteLn(f);
m: =n;
while z[p[m]+d[m]]>m do begin
d[m]:=-d[m]; m:=m-l; end;
pm:=p[m]; dm:=pm+d[m]; w:=z[pm];
z[pm]:=z[dm]; z[dm]:=w;
zpm:=z[pm]; w:=p[zpm]; p[zpm]:=pm; p[m]:=w;
end;
end;(Effect)
Var (Main)
z :Vector;
n :Integer; { }
Hour,Minute,Second,SeclOO :Word;
rHour,rMinute,rSecond,rSeclOO :Word;
delta :LongInt;
begin
Assign(f,'Effect.in' ) ;
Reset(f); { }
ReadLn(f,n); { )
Close (f);
Assign(f,'Effect.out');
Rewrite(f); { }
GetTime(Hour,Minute,Second,SeclOO);
Effect(z,n);
GetTime(rHour,rMinute,rSecond,rSeclOO);
delta:=rHour-Hour;
delta:=delta*60+rMinute-Minute;
delta:=delta*60+rSecond-Second;
delta:=delta*100+rSeclOO-SeclOO;
WriteLn(f,' =',delta div 100,'.',
delta mod 100,' ');
Close(f);
end.

4.3.

75

4.6.

^include <stdio.h>
ttinclude <stdlib.h>
^include <time.h>
^include <dos.h>
void main ( ) { //
// z[l], z[2], ..., z[n]
int n;
int *z,*p,*d;
FILE *f;
struct dostime_t t,tnew;
long delta;
unsigned long k;
int pm, dm, zpm;
int i,m, w;
_dos_gettime (&t) ;
f=f open ("primer. in", "rt") ; fscanf (f , "Id", &n) ;
z= (int*)malloc ( (n+2) *sizeof (int) ) ; //
p= (int*)malloc ( (n+2) *sizeof (int) ) ; //
d= (int*)malloc ( (n+2) *sizeof (int) ) ; //
fclose (f ) ;
f=f open ("primer. out", "wt") ;
for( i=l; i<=n; i++ ){ z [i]=p [i]=i
d[l]=0; z[0]=z[n+l]=m=n+l; k=0;
while ( m!=l ) {
//
k++; fprintf (f, "\n%ld) ",k);
for( 1=1; i<=n; i++ ) fprintf (f, "%d", z [i] ) ;
m=n;
while ( z [ p [ m ] + d [ m ] ]>m ) { d[m]=-d[m]; m ; )
pm=p [m] ; dm=pm+d[m); w=z [pm] ; z[pm]=z[dm]; z[dm]=w;
zpm=z [pm] ; w=p[zpm]; p[zpm]=pm; p[m]=w;

free (z) ;
free (p) ;
free (d) ;
_dos_gettime (Stnew) ;
delta=tnew.hour;
delta-=t .hour;

delta*=60;

4.

76

delta+=tnew.minute;
delta-=t.minute; delta*=60;
delta+=tnew.second; delta-=t.second; delta*=100;
delta+=tnew.hsecond; delta-=t.hsecond;
f p r i n t f ( f , " %ld.%ld ",
(long)(delta/100),(long)(delta%100));
fclose(f);

4.4.
{ 2,..., }
- ,,
, /- .
,
. , 2, 4.7.
{alt
2,..., ] 4.8,
+1.
4.7. 2

for i = 0 to do bj = 0;

/=0;
while bn 1 do

while bi = ldo{bi
l'b, =1

4.8.

Print(S),

/=0;
while an+l eS do

while a.r e S do \ . ~ ,
[/=/+!;

4.4.

77

. (>2)
: Oj, 2,..., , , {1,2,..., 9},
w. ,
2,..., , ,
+,- ,
. , 15 2,..., 1,
2,..., 9 = 5, :
12+34+56+78+9. , .
, :
.
.
at, a2,..., .
.
:
14
71
6 5 8 8 4 7 5 2 3 4 5 7 8 9

:
6+5+8+8+4+7+5+2+3+4-5+7+8+9
6+5+8+8+4+7+5-2-3+4+5+7+8+9
6+5+8+8+4+7-5+2+3+4+5+7+8+9
6-5+8+8+4+7+5+2+3+4+5+7+8+9

=
=
=
=

71
71
71
71

= 0.60 .
,

2,..., ,
. 1,
2"~1 , + 1, 0.

4.9. SubSet () 4.7
2 ( 1)-
. Summa () ,
, + 1, 0.

78

4.

4.9. Pascal '



Program Lucky_ticket ; { )
uses CRT, DOS;
Const
max_n=20;
Type
Vector=array [1 . .max_n] of Longlnt;
Procedure Summa ( var f : Text ; var a , b : Vector ;
n , m : Integer ) ;
Var
S : Longlnt;
i : Integer;
begin
S:=a[l];
for i:=l to n-1 do S:=S+ (2*b [i] -1) *a[i+l] ;
if S=m then begin
Write (f ,a[l] ) ;
for i:=l to n-1 do begin
if b[i]=l then Write {,'+') else Write (f ,'-');
Write (f,a[i+l] ) ;
end;
WriteLnff,' = ',3:4,' - !');
end;
end;
Procedure Subset ( var f:Text; var a: Vector;
n,m: Integer );
Var
b: Vector;
i : Integer;
begin
for i:=l to n do b[i]:=0;
while b[n]ol do begin
Summa (f , a,b, n,m) ;
i:=l;
while b[i]=l do begin
end;
end;
end;

4.5.

79

Var (Main)
a
:Vector;
n,m,i :Integer;
f
:Text; { }
Hour,Minute,Second,SeclOO :Word;
rHour,rMinute,rSecond,rSeclOO :Word;
delta :LongInt;
begin(Main)
Assign(f,'Number.in' );
Reset(f);{ }
Read(f,n); { }
Read(f,m); { )
for i:=l to n do Read(f,a[i]);
Close(f);
Assign(f, 'Number.out' ) ;
Rewrite(f); ( }
GetTime(Hour,Minute, Second, SeclOO) ;
SubSet(f,a,n,m);
GetTime(rHour,rMinute,rSecond,rSeclOO);
delta:=rHour-Hour; delta:=delta* 60 + rMinute-Minute;
delta:=delta*60+rSecond-Second;
delta:=delta*100+rSeclOO-SeclOO;
WriteLn(f); WriteLn(f,' =',
delta div 100,'.',delta mod 100,' c');
Close(f);
end{Main}.

4.5.


k {0, ..., _{\
^- : - ,,
r-. /.
. , k = 2 = 3

: 00,01,02,10,11,12, 20,21,22.
(00), (0{), (2), (^), (^), (^), (2). ( a 2 f l i)> (o22) 4.10 bk k ,

80

4.

bj {, 1,..., 1}, /' = , 1,..., k, .. 6,


.
4.10.
k-
Awr(6*_i>**-2>-A));

/=0;

while bk * 1 do

whilebj =n-ldo\ .'_~ '

bt =6, +1.

4.6.
{alt a2,...,
}, , . k, * :. ,
,
{1, 2,..., }; ,
k {1,2,..., }. , ,
Cl =20 (..
{1,2,3,4,5,6}) :
123 135 234 256
124 136 235 345
125 145 236 346
126 146 245 356
134 156 246 456

. (1,
2,...,k} , , . ,

, 4.11.
* , * +(%).

4.6.

81

4.11.

for i = 0 to k do / = i;
Print(ci,c2,...,ck);
while j 0 do while Cj = n - k+j do j = j -1;
Cj = Cj +1;
oc, =c, , +1.
. .
(*j, {), (2, 2),---, (, ) .
, ,
. , .
. (, ,) . ,
: 0 , 1 , .
:
15
0 0 9 9 5 1 2 3 2 7 11 5467 1 5 6 7 3 4 5 7 7 8 8 7 6 4

:
1 1 1 0 1 0 0 0 10000 10
. , . ,
(Xj ,) ,
,
(xb yj, (x2, ?),..., (, ), (xt ,-). 3 + 0(3). (xir ,) 0( ).
Pascal 4.12.

82

4.

4,12.
Program Start_Envelope; { }
uses CRT,DOS;
const n_max=100;
type

Vector=array[1..n_max] of Integer;
Combine=array[0..3] of Integer;

var f
:Text; ( }
x,y :Vector; { )
z
:Vector; { }
Procedure Envelope( var :Combine; n:Integer );
( }
Const k :Integer=3;
Var
i,a :Integer;
kl,k2,k3 :Integer;
signl,sign2,sign3 :Integer;
begin
VI

<~ i? &.1 j , V\
j\.x > *~OM
L J1. J, V9
?*..
j v j .1~
L- 7
i ~1j j f
for i:=l to n do begin
if (i=kl) or (i=k2) or (i=k3) then continue;
a:=(x[kl]-x[i])*(y[k2]-y[i])if a=0 then continue; signl =a div abs ( a ) ;
a:=(x[k2]-x[i])*(y[k3]-y[i])(x[k3]-x[i])*(y[k2]-y[i])
if a=0 then continue; sign2 =a div abs ( a ) ;
a:=(x[k3]-x[i])*(y[kl]-y[i])if a=0 then continue; sign3 =a div abs (a) ;
if (signl=sign2) and (sign2=sign3) then z[i]:=0;
end;
end;
Procedure Print ( var : Combine ; n : Integer ) ;
Var i : Integer;
begin
WriteLn(f ) ;
for i:=l to n do Write (f , [i] , ' ' ) ;
end;

4.7.

83

Procedure Combination( n:Integer );


{ 3}
Const k :Integer=3; { }
Var
:Combine; {}
i,j :Integer;
begin
for i:=l to k do c[i]:=i;
j:=l;
while j<>0 do begin
{Print(c,k);}
Envelope(c,n);
j:=k;
while c[j]=n-k+j do j:=j-l;
c[j]:=c[j]+l;
for i:=j+l to k do [i]:=c[i-1]+1;
end;
end;
Var (Main)
i,n :Integer; { }
begin {Main}
Assign(f,'Envelope.in');
Reset(f); { }
Read(f,n); { }
for i:=l to n do begin Read(f,x[i],[i]); z[i]:=l;end;
Close(f);
Assign(f,'Envelope.out');
Rewrite(f); { }
Combination(n);
WriteLn(f); {:
}
for i:=l to n do Write(f,z[i],' *);
Close(f);
end. {Main}

4.7.

(z\,
z2,..., zk], Zi + z2 + ... +zk = n.
{^i, Zi,--, zk} ,
,. , , , > 0, , > 0.

84

4.

{^i, Zi,, Z^} ,


Zj> 0 , . {z\, Z},, Z/J
(. . 1.8).
= 3.
(1, 2), (2, 1) , / > 0.
(1, 1, 1) , z\ > 0.
(, 3), (1, 2), (2, 1), (3, 0) , z,> 0.
(3), (1, 2), (1, 1, 1) .
z, >
[z\, Zi,-, zd, Zj > 0, z\ + Zi +-+ z^ = n
.
Zj= 1,+ 1/ + ... + 1/ , zt. 1,- Zj. , k {1 12,..., 1*}, . , {Ij, 12,..., 1*}.
1, , , .
, ,
C"k = C^_j = C^ +A _j.
C"+k_{ 1
+ k - 1, k - 1 , .. ( + k- 1)-
; .
( k - 1),
z\ ( k) . ,
c
+*-i =ci7?+7-i 11011100111101111111010
(2,3,0,4,7,1,0) 17.
, , S 0.
zt >
,
. - 1 ,

4.7.

85

. .

(2,1,2,2,1) = 8. , - 1 .
, , , ( - 1)-
. ( - 1)- k - 1 ,
C*J/ .

Zj > 0. , z\ + Z2 +...+ zk =
Zj > 0, , = z, - 1, (,- > 0) (/*!, 2,..., rk) n-k =
=r
i + 2 +"-+ rk> ri - - , > 0 (1;
r2,..., rk) ,
, , zf> 0
{Zi, Z2, , Zk}
,
, , ,
, , 1+1+2,1+2+1, 2+1+1. ,
, :
{mlzl,m2z2,..-,mkzk},
\ z\, 2 z2, 3
k

. . = ^/,,.
/=1
Zi > z2 > ... > z^
= 7.

.
, , k zk . mkzk -

86

4.

(mk > 1), zk ,


zk + 1 ( ^ + 1 ,
). mk = 1, m^Zk-i + mkzk
, Zk-\ + 1. , ,
.
{VI)

=(1,1,1,1,1,1,1)

{12,5}
{2'2,3'1}
{3-2, 1-1}
{1-3, 4-1}
{1'3,12,2}
{1-3, 2-2}
{2*3, 1*1}
{1*4, 3*1}

={2,1,1,1,1,1}
={2,2,1,1,1}
={2,2,2,1}
={3,1,1,1,1}
={3,2,1,1}
={3,2,2}
= { 3 , 3 ,,1}
={4,1,1,1}
={4,2,1}
={4,3}
={5,1,1}
={5,2}
={6,1}
={7)

{1*4, 1*2, 1*1)


(1-4, 1-3}
{1-5, 2-1}
{1*5, 1-2}
{1'6,1'U
{1'7>

4. 13 .
4.13.
k=\;

\ = ;

while k 0 do

Print{ml zl,m2
Summa = kzk\
{k-k-V
ifmk=lthen\~' l> c
[Summa = Summa + mkzk',
ifZk-i

=z

k +lthen

elsel k .k
\mk =1;

'

if Summa >zk then \mk+l = Summa-zk',

4.7.

87

4.13 , ,
, , k.
Pascal 4.14. , ,
. ,
.
4.14. Pascal'

Program Start_Divide; ( )
uses CRT,DOS;
Const
max_n=100; { n<=max_n }
Type
Vector=array[-1..max_n] of Integer;
Var
f
:Text;
z,m :Vector;
Procedure Print( var m,z:Vector; k:Integer );
{ }
Var
i :Integer;
begin
Write (f, ' { );
for i:=l to k do begin
Write(f,m[i],'*',z[i]);
if iok then Write (f,',');
end;
WriteLnff,' }' ) ;
end;{Print}
Procedure Divide( n:Integer ); { n)
Var
k,Sum :Integer;
begin;
k:=l;
z[-l]:=0;
m[-l]:=0;

88

4.

z [0] :=+1;
[0] :=0;

:=;
while k<>0 do begin
Print (, z, k) ;
Sum:=m[k] *z [k] ;
if m [ k ] = l then begin
k:=k-l;
Sum : =Sum+m [ k ] * z [ k ] ;
end;
if z [ k - l ] = z [ k ] + l then begin k:=k-l; m [ k ] : =m[k] +1; end
else begin z [k] :=z [k] +1; m [ k ] : = l ;
end;
if Sum>z[k] then begin
:=Sum-z [k] ;
k:=k+l
end;
end;
end; {Divide}
Var {Main}
n : Integer; { }
Hour, Minute, Second, Seel 00 :Word;
rHour, rMinute, rSecond, rSeclOO :Word;
delta rLonglnt;
begin
Assign ( f , ' Divide . in' ) ;
Reset (f); { }
ReadLn(f,n); { n}
Close (f) ;
Assign ( f , ' Divide . out' ) ;
Rewrite (f); { )
GetTime (Hour, Minute, Second, SeclOO) ;
Divide (n) ;
GetTime (rHour, rMinute, rSecond, rSeclOO) ;
delta : =rHour-Hour ;
delta:=delta*60+rMinute-Minute;
delta :=delta* 6 0+r Second-Second;
delta :=delta*100+rSeclOO-Secl 00;
WriteLn (f, ' =' , delta div 100,'.',
delta mod 100,' ' ) ;
Close (f ) ;
end.

4.8.

89

4.8.
= (nlt 2,..., ) 1, 2,..., , , = (1, 2,..., ) .
() = (1; 2,..., )>
(. .7.4).
,
.
. rand(k,t),
[k, l\ .
(0) = (Tc ( j 0) , (20),..., TcJ,0))
= ( 2,..., ). TCW =((1),(2/),...,
^') **'1' = (^'1) ,n(2k~l),
...,^*~1)) ^-1) (*~]*

;= 1,2,...,

. , ,..., (;> =("-1) =..-=n[k), k=l, 2,..., .


, ! = (a ls -2,...,) 1,2,...,. , (('^ = ) = \/\. AI, 2,..., .

_V =0-^}, k = 2,..., .

,
(0)
(0)
, (1),..., (),
Pi(Ak) = !/(- k +1), = 1 , 2..., .

90

4.

**'1* =1&(2/:"1) = 2 &...&^ 1) =ok_l


k = 2,..., , n(krand(kjt)
~1),, ,
{^* 1),(*~1),...,^ ^J, {,
+1,..., }. rand(k, n) n^J*


[k, n] .
,
(() = )=((1") = 1&2") = 2 &...&< ) =) =
= ((11) = 1 & ( 2 2) = 2 &...&<, ) =) =


4.15.
4.15,
for k=\ to n do nk = k; { }
for k = 1 to n - 1 do uk - nrand(krf>; { }
, ,
for k = 1 to n do nk - k\ { ]
for k = n to 2 do nk <- Krand({^)\ { }.


.


. , , .
,
. ,
. ,
, ,
.
. , ,
0(),
0(log2).
: alt 2,..., , ,
, .. ,, 7- , < Oj, , < ,, = Oj, , > , , > Oj.
n = (nl,n2,...,nn) ,

<2 <...< . ,
, .
(
) (
).
, ,
. -

92

5.

, , .
,
. .
. . ? , ,
.
, ; , , .

. , . ,
.

5.1.
2,..., ( 5.1). 0,
-. = 2,
3,..., ; j ,-
1; 2,..., o/_i. ^ \\> _ 1( Oj_2,..., a^, w , ,
w. 0, -
.
5.1.
0 =

'=7-1;
w=a
j>
forj = 2 ton do{

I a,., =a,-;
while w <o. do { '+1

ai+1=w.

[/=/+1;

5.2.

93


w < djB . w < , w = , (/' > 2) 1 + ^, dj , Oj , .. dj ,
,-. dj dld2...dn,
0 < fl"i < - 1, 0 < d2 < - 2,..., < dn_v < 1, dn = 0,

ab a2,..., an ~^(l + d j ) <


j'2

..

n(n-l)

2
n.

<2_l(l+n-j) = - - - = 0(n ) .
>2

5.2.
2,...,

, ,
. ,
. 5.2. , t, ,
+1, 1+2,..., . ,
.
5.2.

while b*Qdo\forj=\tob-\do

if a} > aj+l then I uj_

[' -J'

(b=t.

uj > aj+i ,- <-> ,+1,
alt a2,..., . . b - 1

94

___

5.

for while
1
1, ^( -1) = ( - 1) +
+ ( - 2) +...+ 1 = - - = 0(2). .
5.3 .
5.2. , .
5.3 ,
2

-/) = ( -1) + ( -2 ) +. . .+ 1 = - - = 0(2 ), 2


.
5.3.
for i = 1 to n do begin
forj = 1 to n - i do begin
> aj+i then } <->

end;
end.

5.3.
1; 2,..., ,
2,..., , ( 5.4). , , cl,c2,--,cn. Cj+l,j= 1,
2,..., . rl; 2,..., .
5.4.
for i = 1 to n do ct : = 0 { }
for i = to 1 by -1 do begin
forj = i - 1 to 1 by -1 do begin
if a/ > Oj then ct = c, + 1

else C = Cj+ I
end;

5.4.

95

end;
for i = 1 to n do begin;
r
c-+i =ai ( ri }
end.'

0(2). 2,..., .
= (17 2,..., ), , ,- + 1, / = 1, 2,..., .
5.4 ~ , < ., <...< i
7]

7I 2

71

(..1.14).

5.4.
alt a2,..., ( ),
. 0(nlogn),
. . , . 5.1.

96-

22

17

28

. 5.1.

,
. , , .
. 5.2.

22

17

28

. 5.2.

96

5.

, 2
0( ) () , ,
, .
alt a2,..., , () .
5.5,
1; 2,...,
( [1..]).
.
. 5.3. [1], a[k]
a[2k] a[2k+l].
, 5.5.
[2]
[5]

[7]

. 5.3.

5.5 SURFACE (a[i..k])


, O(log2)
.
a[i..k], .5.4, a[i]
, a[k] , .

a[k]
. 5.4. a[i..k]

5.4.

97

SURFACE . , (
) ( )
, .
. ,
( ) ,
h = 0(h). h
1
1
< 2 + 2 +...+ 2 ~ ,
1
2'" /- , / = 1, 2,..., . = flog 2 (w + 1)1. ,
SURFACE O(log2).
SURFACE () 0(log2),
.
.
2,..., 5.5 SURFACE

. , , , , ,
, . , , , ,
. 5.5
.
, () . 5.5 ( ),
()
SURFACE .
. 5.5
, 42697

98

5.

,
, .
-* 18 -*

/ \

65

- 66 -^-- 56

/ \

66

65

37 63/\56

/ \

63

37 18/\56

65

63

37 18/

66

-+65 -> - 18 -

/\
56
63
/\
4 37 18 66

-* 37 -*

56
4

18

63 65

- 63

\18
56

4 37 65 66

-> 56 -> -> 4

37
66

/\
56
63

37 65 66
18

63 65

37
66

18

56 63 65

66

--37 -> -* 18 -+ > 18

18

56 63 65

66

-* 4

18
56 63 65

37
66

. 5.5. 18,4,56,65,37,63,66

5.5. 0(12)
Program Floid; {
}
uses CRT;

const n = 1000; { }
type
Vector = array[l..n] of Integer;
Var
f :Text; { }

5.4.
procedure Init( var a: vector; n: integer);
{ a[l..n] }
var
i: integer;
begin
Randomize;
for i:=l to n do a[i]:=Random(100);
end;
procedure Surface( var a: Vector; i,k: integer);
{ a[i..k] }
var
j,m,copy :Integer;
begin
copy:=a[i];
m:=2*i;
while m<=k do begin
if m=k then j:=m
else if a[m]>a[m+l] then j:=m else j:=m+l;
if a[j]>copy then begin
a[i]:=a[j];
i:=j;
m:=2*i;
end
else break; { }
end;
a[i]:=copy;
end;
procedure Sort( var a: Vector; n: integer);
{ a[l..n] }
var
i,k,w :Integer;
begin
{ }
for i:=n div 2 downto 2 do Surface(a,i,n) ;
{
}
for k:=n downto 2 do begin
Surface(a,1,k);
{
}
w:=a[k]; a[k]:=a[l]; a[l]:=w;
end
end;

99

100

5.

Var {Main}
: Vector; { }
i : Integer;
begin; {Main}
Assign(f,'sort.out');
Rewrite(f); { }
Init(a,n);
{ }
for i:=l to n do WriteLn(f,'a[ \ i:I,']=',a[i] :3);
Sort(a,n);
{ }
WriteLn(f);
for i:=l to n do WriteLn(f, ' s[ \ i:1,']=',a [i] :3);
Close(f);
end. {Main}
. SURFACE

( )
() .
SURFACE
0(12),
2,..., 0(log2).
, , . , {, 2,...,
\
.
! Iog2! .
\~ J2nnnne~".
Iog2! ~j2nnnne~n =0(log2).
. .
: 1 2, 2,..., , . [,-, ,], / = 1, 2,..., .
. .
: . , .. - bi
. .

5.4.

101

-1 1
1

. 5.6 al, 2, 2,..., ,


ab[l..2n]. g[1..2n],
ab[\..2n]
: g[i] = 1 , g[i] = 0 .
ab[1..2n] . . 2
0( ).
5.6.
Program MeasureLength; { )
uses CRT,DOS;
const n_max=100;
type
Vector=array[0..2*n_max] of Integer;
var
f
:Text; { }
ab :Vector; { a[i], b[i]}
g
:Vector; ( : 1-, 0-}
Procedure Measure( Var m: Longlnt; n:Integer );
{ }
Var
i, : Integer/begin
ab[0]:=ab[1];
m:=0; { }
c:=0; { }
for i:=l to n do begin
if coO then m:=m+ab[i] -ab[i-l] ;
if g[i]=l {- } then c:=c+l else c:=c-l;
end;
end;

102

5.

Procedure SortBubble( n:Integer );


{ a[i],b[i] g[i]}
Var i,j,w :Integer;
begin
for i:=l to n do begin
for j:=l to n-i do begin
if ab[j] > ab[j+l] then begin
w:=ab[j]; ab[j]:=ab[j+1]; ab[j+l]:=w;
w:=g[j]; g[j]:=g[j+1]; g[j+l]:=w;
end;
end;
end;
end;
Var (Main)
i, k :Integer;
n
:Integer; { }
m
:LongInt; { }
begin (Main)
Assign(f, 'Measure.in');
Reset(f); { }
Read(f,n); { }
for i:=l to n do begin
k:=2*i;
Read(f,ab[k-l],ab[k]);
g[k-l]:=l; { }
g[k]:=0; { }
end;
Close(f);
Assign(f,'Measure.out');
Rewrite(f); { }
SortBubble(2*n);
Measure(m,2*n);
WriteLn(f,m); { }
Close (f);
end. {Main}

5.5.
. , , ,
.

5.5.

103


{, 2,..., ,
. ,
; .
. 5.7
z alt
2,..., . ,
.
5. 7,
= 0; ( }
=]
'
break;

ifc=l then else .


als
2,..., . /- , / .

. , , .. . -

-,.
, .
- > / = = 0() .
2


. , (

) /, / > 0 ^,- =1.


/=1
( )

] /, . (=1

: , = >
/ = 1, 2,..., . (. . , - , .)

, ^], = 1. /=i
,..., .

104

__

5.

= - = -
,
.
.
1

+\
> = > i-=n-c - - - , - .

ft
/
1'
2
, , . , , ,
, .
2,...,
.

5.6.
( )
GJ < 2 < < > . ,
, . :
, .. , 1+ , .
_

L 2 J

, tfj, U2,..., , 1+ ,,..., ,


, ..
, . ,
^ < 2 < ... <
, .
, ( ) :
{ } < <{
}.

5.6.

105

, ,- < a,+i <...< ,-. a, i + j , , \ '-^- ]


, (/ +f)/2. ai+i,..., a, U J , ,
[~\

\ ,; i ). Oj_i, uj. . 5.6


,
{, 2,..., .

5- "

^9

. 5.6. ,
: 3,5,7,9,12,19,27,44

z \ < a2 <...< 5.8.


5.8. z al < a2 <...<
/ind=Q; { }
/ = 1; { }
j = n; { }
while i <j do begin
= '-L ; { }
ifz= am then \** ~
I &FCUK

{ ]

else ifz > then i = + 1 { }


elsej = 1 { }
end',
if find = 1 then ;
else .

106

5.

e t <
< 2 << ( 5.6).
, . . .5.4 , flog2(n + 1)1. , 0(12), .
,
ai < 2 <...< . ,

j < a2 <...< .

5.7.
{, 2,..., = ( 2,..., ) <ani <... <. ,
, , . at

() bn br+l,..., bs, ba. = d j . < <...< bs, , 2,..., .

ait a2,..., aj, 6,3,5,7,2, 4, 1 1 7.
, bl < 2 <...< 7, bj
for /'= 1 to I doba. = d j .

0(), = 1. , ,
= ( 2,..., ) =(7,5,2,6,3,1,4),
< 2 <...< . ,
for i= I to 7 dona =/'.

5.7.

107

,
6, 3, 5, 7, 2, 4, 1
.
2,..., . , \, 2,..., .
2,...,
5.9.
br, br+l,.,., bs, r=mm(al, 2,..., )
s = max(ai, 2,..., ),
15 2,..., . br, b^,..., bs
s + 1, flj, 2,..., .
5.9.
^, 2,...,
{ min max alt a2,..., }
r = s = al;
for i = 2 to n do begin
ifr>a, then r= a,
else ifs < ai then s = a,
end;
{ bt s+l, at}
for i = rtosdobj = s+ 1;
{ ^, 2,..,, }
for i = 1 to n do ba. =a,;
{ \, 2,..., bn b^.b.,., bs}
k = 0;
for i-r to s do begin
ifbj#S+ 1 then begin

k = k+l;
a
k = */;
end;
end.
a x < a2 <...< an
bn b^i,..., ^
,

108

5.

s + 1. , , ().

,, 2,...,
5.10.
alt a2,..., , , , = /,
ba = atw.ba = 7 flj, 2,..., . , , .
, . 1; 2,..., dr, drf-i,..., ds {, 2,...,
1 2,..., . 5.9
{,
2,..., , .
dn df+i,..., ds , 2,...,
1 2,..., . cr, c^,..., cs
flj,
2,..., dr, d^i,..., ds.
5.10.
\, 2,...,
{ min max 2,..., }
r = s = al;
for i - 2 to n do begin
ifr> at then r= at
else ifs < a, then s = a,
end',
{ a,}
for i = r to s do Cj = 0;
for i = 1 to n do ca. =ca. +1;
{ dr, d^^..., ds }

dr=\;

for / = /+! to s do dt, = flf,._! + Cj_i,


{ ui, a2,..., bi,b2,...,bn}
for i = 1 to n do begin
k = a,;

5.7.

end.

109

1;
2,..., 1<2< ... < . ,
0().
, s - re
,
CH-IV, , dn dm,..., ds.

6 =*^
.

I , ..
. , , , ,
, ,
, ,
.. .

6.1.

.
=(, U, ), ; U (); ;
Xr\U=0. (, , ), , X, U,
( ),
( ) :
1) Vw U , & (, , ) .
2)(, , )*(', ,'))^(( = ' = ')( = ' = ')) , .

1. X .
2. (, ,)-, (, , )
, .
3. (, , ) (, , ) .
4. (, , ) .


1. .
2. - .
3. 4.

.
.

6.1.

111

. 6.1.

. /\ = (\, Ul} ^ 2 = (2, U2, 2)


(7\ = 2), : \ -> 2 : C/j -> U2,
: 2((1),\|/(1),(>'1)) = 1(1,1,.1).
,
(. 6.2).
2

7^.1

. 6.2.

. {),
: V j c ^ y e J f V w e U
(, , ) => -:(, , ).

.
. = (X, U, )
= (\ U', ), '^, U'cU. .
. , , . .
.
(. 6.3).

. 6.3. () ()

112

6. .

. ,
.
. ,
. ^ (. 6.4).

. 6.4.

. /
, , (. 6.5).

. 6.5.

. (),
,
.

. 6.6. -| , ,

. , , , , . ,
.
. , . , 0, ,
1, .

6.1.

113

. ( ), - (. 6.7).
,

. 6.7. /~| , -i

. () - (X, U, ) 1122^...+1,
jc, X, Uj U. ,
xi+l, .. ( /+1).
, .
, xi = xn+j.
.
,
.
.
,
.
, .
. =(, U, ) ,
, X jc ( ).
. , ( ) (. 6.8).

. 6.8. /~| , 2

.
, .

114

6. .

. 6.9.

/~! ,

, , ..
.
, .
.

6.2.
() () .
.
. , , , .
.
, .
.
, .

6.2.1.

. = [/}],
i,j= 1, 2,..., ,
_ 1, (xt ,Xj),
10, / ,Xj (;, ,Xj).

6.2.

115

.
. 6.10 . 6.11. ,
. , 1, ,
.

. 6.10.

"0

0
0
0

1 1 0 0
1 1 1

0
0
0
0
0

0
0
0
0
0

0
0
0

1
1

1 1
1 1

0
0
0
0
0
0
0

0"

. 6.11. . 6.10

6.2.2.

.
= [by], i = 1, 2,...,, j = 1, 2,..., , , .
_ J1, , ,-,
'* 10, jc, ,.

.
[],

116

6. .

/ = 1, 2,...,, j= 1, 2,..., , , .
+1, ;,,
-1, Uj ,,
, , Uj.


. . 6.12
. 6.10.
1 1 2 2 1 1 2 1 1 1 1 . 6 6 6 1 7
2 3 1 3 4 5 7 5 1 5 7 4 5 7 4 5

]+1 + 1 - 1 0 0 0 0 0 - 1 0 0 0 0 0 0 0
2-1 0 + 1 + 1 + 1 + 1 + 1 0 0 0 0
3 0 - 1 0 - 1 0 0 0 + 1 0 0 0 0 0 0 0 0
0-1 0 0 0 + 1 + 1 + 1 - 1 0 0-1
0 0 0 0-1 0-1 0 - 1 0 0-1 0 0 - 1
0 0 0 0 0 0 0 0
0 0 0 + 1 + 1 + 1 0 0
0 0 0 0 0 - 1 0 0 0-1 0 0 - 1 + 1 + 1
. 6.12.

6.2.3.

. ,
.
W= [wy\, Wy
, i,j= 1, 2,..., . QO 0
. ,
.

6.2.4.
.
r=(rl,r2,...,rm)ut=(tl,t2,...,
tm), .
, /- ,
tt. , . 6.10 :
= (1,1,2, 2, 2, 2,2, 3, 4, 4, 4, 6, 6, 6, 7, 7),
=(2,3, 1 , 3 , 4 , 5 , 7 , 5 , 1 , 5 , 7 , 4 , 5 , 7 , 4 , 5 ) .

6.3.

117

,
.

6.2.5.

.
Adj[x] ,
. Adj[x]
. , . 6.10.
Adj[x}

X,

1
2

2, 3
1,3,4,5,7

4
5

1,5,7

4,5,7

4,5

( ) .
, ,
.
, .
, .

6.3.

,
(. .4.1).
= (X, U, ) . : X,
(, ), X.
( ),

118

6. .

. ,
.
, , ,
(s, x), , , s X. , , .
. , , ,
(, ), , , jc ,
, .
,
.
6.1.
Depth(x, w) = (X, U, ),
; X, ,
0 = (X, , )
( , 0 ); w e '
, .
Adj[x], Adj[x] , X. , , 0, . ,
. , Mark[x] , 1 (A'l
, . Mark[x] = 0
X , , , Mark[x] . (, v) , Mark[v] = 0.
Mark[v] , , (, v) & , Mark[v] < Mark[x] v * w.
Mark[v] < Mark[x] , v
. (, v) ,
, w , . . v * w.

6.3.

119

. ,
, Depth , \\.
,
. 0(\\ + \U\).
6.1.

for v X do Mark[v] = 0;
count= 0;
=0; 5=0;
for v e Xdo ifMark[v] = 0 then Depth(v, 0);
procedure Depth(x, w);
count= count+ 1;
Mark[x] = count;
for v e Adj[x] do begin
ifMark[v] = 0 then
T= T^J {(x, v)}; { }
Depth(v, x);
else ifMark[v] < Mark[x] and v w then
B = .Su {(x, v)}; { }

end;
end.
6.1 6.2.
6.1. Init, Depth, WayDepth, WayDepth ;
Depth , 6.1; /m'f
. . 1 \\.
,
, .
Adj[x] .
for v e Adj[x] do ... -

120

6. .

for i=lto Nbr[x] dov = Adj[Fst[x] + /']..., Nbr[x]


X;
Adj[x] ,
; Fst[x] + 1 X, Fst[x] + i /- X.
, Adj[x]:
AdJM

2, 3,5

2
3
4
5
6
7

1, 3 , 4
1, 2 , 4 , 5
2, 3
1, 3 , 6 , 7

5,7
5, 6


i\x\
Fst[x]

3 3 4 2 4 2 2
3 6 10 12 16 18

235 134 1245 23 1367 57 56


6.2

Adj[x]:
, ;

, , , .
6.2 , . 6.13. ,
, .

. 6.13.

6.3.

121

. 6.13 Depth, in:


7
13
23
34
42
54
62
72

2 3
13
1 2
23
1 3
57
56

5
4
4
6

Depth.out
:
2
1

3
1

1
0

4
1

2
0

5
1

1
0

6
1

!
TvB

( ,) , 1 0, ,
.
6.2.

Program PgmWayDepth; { )
uses CRT,DOS;
Const
nVertex=100; { }
nAdjacent=1000; { }

TypeVertex=array[1..nVertex] of Integer;
TypeAdjacent=array[1..nAdjacent] of Integer;
Var
f
:Text;
{ }
n
:Integer;
{ }
nT
:Integer;
{ }
Adj :TypeAdjacent; { }
Fst :TypeVertex; { }
Nbr :TypeVertex; {
}
Vtx :TypeVertex; { }
Mark :TypeVertex; { }

:TypeVertex; {
}

122

6. .
:TypeVertex;

{
}

Procedure Init( Var yes :Boolean );


{ }
{ }
{ yes - }
Var
i, j,m :Integer;
begin
for i:=l to n do
for j:=l to Nbr[i] do begin
yes:=FALSE;
for m:=l to n do
if Adj[Fst[i]+j]=vtx[m] then begin
yes:=TRUE;
Adj[Fst[i]+j]:=m;
break;
end;
if not yes then exit;
end;
end;
Procedure Depth( x,u:Integer; var count :Integer);
Var
i,v :Integer;
begin
count:=count+l;
Mark[x]:=count;
for i:=l to Nbr[x] do begin
v:=Adj[Fst[x]+i];
if Mark[v]=0 then begin
nT:=nT+2; T[nT-l]:=x; T[nT]:=v;
B[nT div 2]:=1; { }
Depth(v,x,count);
end
else if (Mark[v]<Mark[x]) and (v<>u) then
begin { )
nT:=nT+2; T[nT-l]:=x; T[nT]:=v;
B[nT div 2]:=0; { }
end;
end;
end;

6.3.

123

Procedure WayDepth; ( )
Var
v,count :Integer;
begin
nT:=0; { - }
count:=0;
for v:=l to n do Mark[v]:=0;
for v:=l to n do if Mark[v]=0 then Depth(v,0,count);
end;
Var (Main)
i,j :Integer;
yes :Boolean;
begin {Main}
Assign(f,'Depth.in');
Reset(f);{ }
( }
Read(f,n); ( }
Fst[l]:=0; { }
for i:=l to n do begin
Read (f,Vtx[i]); { }
Read(f,Nbr[i]); ( }
for j:=l to Nbr[i] do Read(f,Adj[Fst[i]+j]);
( }
Fst[i+1]:=Fst[i]+Nbr[i]; (
}
end;
Close (f);
Assign(f,'Depth.out');
Rewrite(f); ( }
Init(yes);
if not yes then begin
WriteLn(f,' !');
Close (f);
exit;
end;
WayDepth;
for i:=l to nT div 2 do Write(f,Vtx[T[2*i-l]]:3);
Writeln(f);
for i:=l to nT div 2 do Write(f,Vtx[T[2*1]]:3);
Writeln(f);
for i:=l to nT div 2 do Write(f,[i]:3); Writeln(f);
Close(f);
end. {Main}

124

6. .

6.4.
~, S, ,
, :
1. Vjj e. S sl~ Sj.

2. Vsj,S2 e S $i ~ $2 > Si ~ s\.


3. V^i, ^2, 53 S $i ~ $2 ~ . $i ~ s^,
S, Sj, St, .
- ,
, 13. ,
S S/ , .. S =(J S j , St n Sj = 0, i #j.
/
. 51 . S
~ . ,
, S ~ Ab, .
, ,
13 .

.

. S - .
S ~ . , a,b e S ~ , . ,
13 .
.
. S= {1, 2,..., ]. 1 ~ . , , q e S ~ q, . . S
.

6.5.

125

. S . S
~ . ,
, ^ ~ &, . .

6.5.
= (X, U, ) .
xl} x2 e ^ ,
xl 2. ~
. 2 ~ , ..
jq ~ 2, . . , *! 2, 2 3, ,
{ 3. ,
,
( , Xt .

= (X, U, )
/= (Xj, Uj, ). ,
,
. ,
.
6.5.1. .

.
6.5.2. = (X, U, ) k .
_+1 =

.
k

= \ \ r ( X j ,Uj ,) .

126

6. .

, Xt *
nh ^..
,
. ,
F(Xj, Ut, ) ,

, 2 - 1 > 1-
/\ 2. ,
k . ,
, k 1 k + 1 .
. ,
2
("-'"- ), .

6.6.
,
. . 6.3

(, U, ). 6.3
6.1
. 6.3 Mark[x] X .
Mark[x] ,
X. 6.3, 6.1, 0(\\ + \U\).
6.3.

for v e Xdo Mark[v] = 0; { }
count = 0; { }
for v e Xdo ifMark[v] = 0 then begin
count^ count + 1;
Component(v, count);
end;

6.6.

127

Procedure Component(x, count)',


Mark[x] = count',
for v e Adj[x] do ifMark[v] = 0 then
Component(v, count);
end;

6.4, 6.3. 6.4
, . 6.14.

. 6.14.

6.4
Adj[x] . 6.14
Connect.in. ()
,
6.2.
Connect.in . 6.14:

11

2
9
8
12
14
3
4
7
15
21

3
2
1
1
3
2
3
2
2
2
1

2 3 4
3 1
7
7
14 15 21
12 15
2 1 4
1 3
9 8
14 12
12

nect.out :
1 2 9 8 12 14 4 7 15 21 ;
1 1 2 2 3 3 1 1 2 3 3 .

128

6. .

6.4.

Program ConnectComponent; {
}
uses CRT,DOS;
Const
nVertex=100; { }
nAdjacent=1000; { }

TypeVertex=array[1..nVertex] of Integer;
TypeAdjacent=array[1..nAdjacerit] of Integer;
Var
f
:Text;
{ }
n
:Integer;
{ }
Adj :TypeAdjacent; { }
Fst :TypeVertex; { }
Nbr :TypeVertex; {
}
Vtx :TypeVertex; { }
Mark :TypeVertex; { }
Procedure Init( Var yes :Boolean );
{ }
{ }
{ yes - }
Var
i,j,m :Integer;
begin
for i:=l to n do
for j:=l to Nbr[i] do begin
yes:=FALSE;
for m:=l to n do
if Adj[Fst[i]+j]=Vtx[m] then begin
yes:=TRUE;
Adj [Fst [ij-t-j] :=m;
break;
end;
if not yes then exit;
end;
end;
Procedure Component( x,count :Integer);
Var
i,v : Integer;
begin
Mark[x]:=count;

6.6.

129

for i:=l to Nbr[x] do begin


v:=Adj[Fst[x]+i];
if Mark[v]=0 then Component(v,count);
end
end;
Procedure Connect; { )
Var
v,count :Integer;
begin
for v:=l to n do Mark[v]:=0;
count:=0; { }
for v:=l to n do begin
if Mark[v]=0 then begin
count:=count+l;
Component(v,count);
end;
end;
end;
Var {Main}
i, j :Integer;
yes :Boolean;
begin {Main}
Assign(f,'Connect.in' ) ;
Reset (f);{ }
{ }
Read(f,n); { }
Fst[l]:=0; { )
for i: =1 to n do begin
Read(f,Vtx[i]);
{ }
Read(f,Nbr[i]);
{ }
for j:=l to Nbr[i] do Read(f,Adj[Fst[i]+j]);
{ }
Fst [i + 1] :=Fst[i]+Nbr[i];{
}
end;
Close(f);
Assign(f,'Connect.out');
Rewrite(f); { }
Init(yes);
if not yes then begin
WriteLn(f,' !');
Close(f);
exit;
end;
52697

130

6. .

Connect;

for i:=l to n do Write(f,Vtx[i]:3); Writeln(f);


for i:=l to n do Write(f,Mark[i]:3) ;
Close (f);
end. {Main}

6.7.
.
,
, . 6.15.
: ,
, , . .

. 6.15.

. = (X, U, ) . ,
. .
.
,
. 6.15, . 6.15,
,
, .
: () .
. .
. . = (X, U, )
, :
1. ;
2. (
);

6.7.

131

3.
# , ;
4. b
a = b,io .
. (=>) ,
aulx2u2...xnunb, , , *, X, , U,
. ,
.
14: 1) , , ; 2) /_,
, , ,
, ; 3) 4) 2.
(<=) 14. . 3 4 *, . 3
. X (. 6.16). ,
, .
( /\) , ,
, , ( ).
: 1) Tj
, ; 2) /i
. \1 , /\. \ {
( ). , /\, \ ^ X. 2 , ^
-12 /\ 2 ,
. 6.16. ,

. 6.16.

132

6. .

,
: Aulx2...au*b...unA. *, flw1/2.,./nwn,
t; e X, Wj e U.

6.5 .
Adj[x], #[] , X.
Z.
6.5.
3v e X', ( }
Z- {v}; ( }
R = 0; { }
repeat
Cycle(v, R);
Z= Z^i R, { }
until Not 3v e Z \Adj[v]\ > 0
Procedure Cycle(v, R)
R= {v}; ( }
repeat
w = Adj[v];
R = Rv(w};
Adj[v] =Adj[v] \ {w}', ( (v, w) }
ifv^w then Adj[w] = Adj[w] \ {v}; ( (v, w) }
v = w;
until Not \Adj[v]\ > 0; ( }
end;
, Z, R. , R ( , Z),
Adj[x] (
). R
,
.
. Cycle , \\.
, .
Cycle -

6.7.

133

\U\s . (\\ + \U\).


6.6, 6.5.
6.6.
Program EilerWay; { }
uses CRT,DOS;
Const
nVertex-100; { }
nAdjacent=1000; { }

TypeVertex=array[1..nVertex] of Integer;
TypeAdjacent=array[1..nAdjacent] of Integer;
Var
f
:Text;
{ }
ks
:Integer;
{ }
n
:Integer;
{ }
Adj :TypeAdjacent;{ }
Fst :TypeVertex; { }
Nbr :TypeVertex; {
}
Vtx :TypeVertex; { }
Deg :TypeVertex; { }
kz
:Integer;
{ }
z
:TypeAdjacent;{
}

:TypeAdjacent;{ }
Procedure Init( Var yes :Boolean );
Var
i,j,k,m :Integer;
begin
{ }
{ }
{ yes - }
for i:=l to n do
for j:=l to Nbr[i] do begin
yes:=FALSE;
for m:=l to n do
if A d j [ F s t [ i ] + j ] = V t x [ m ] then begin
yes:=TRUE;
Adj(Fst[ij+j]:=m;

134

6. .

break/end;
if not yes then exit;
end;
{ }
for i:=l to n do begin
k:=l;
for j : = l to N b r f i ] do if A d j [ F s t [ i ] + j ] = i then begin
Adj[Fst[i]+j]:=Adj[Fst[i]+k];
Adj[Fst[i]+k]:=i;
k:=k+l;
end;
end;
{ )
for i:=l to n do begin
Deg[i]:=0;
for j:=l to Nbr[i] do begin
Degfi]:=Deg[i]+l;
if Adj[Fst[i]+j]=i then Deg[i]:=Deg[i]+1; {}
end;
end;
( ks }
k:=0; ks:=l;
for i:=l to n do if ( Deg[i] mod 2 ) > 0 then begin
k:=k+l; ks:=i;
end;
if ( k<>2 ) and ( k<>0 ) then yes:=FALSE;
{ }
end;
Procedure Cycle( v :Integer; var count :Integer );
{ [] }
Var
w
:Integer;
i,j
:Integer;
begin
count:=l; r[count]:=v;
repeat
w:=Adj[Fst[v]+1]; { }
count:=count+l; r[count]:=w;
{ (v,w)
v }
Fst[v]:=Fst[v]+l;
Nbr[v]:=Nbr[v]-l;

6.7.

135

{ (w,v) ,
w }
if vow then
for i:=l to Nbr[w] do if Adj[Fst[w]+i]=v then begin
for j:=i+l to Nbr[w] do
Adj[Fst[w]+j-l]:=Adj[Fst[w]+j];
Nbr[w]:=Nbr[w]-1;
break;
end;
v:=w;
until Not( Nbr[v]>0 );
end;
Procedure Eiler; { z[] }
Var
v,w
:Integer;
i,j,kt
:Integer;
count
:Integer;
yes
:Boolean;
begin
v:=ks; kz:=l;
kt:=kz; z[kz]:=v;
Write (f,'Z=');{ }
for i:=l to kz do Write(f,Vtx[z[i]]:3); WriteLn(f);
repeat
Cycle(v,count);
Write(f,'R=');
for i:=l to count do Write(f,Vtx[r[i]]:3);
WriteLn(f);
for i:=l to count-1 do begin
z[kz+i]:=z[kt+i];
z[kt+i]:=r[i+l];
end;
kz:=kz+count-l;
Write (f,'Z=');{ }
for i:=l to kz do Write(f,Vtx[z[i]]:3); WriteLn(f);
yes:=FALSE;
for i:=kz downto 1 do if Nbr[z[i]]>0 then begin
v:=z [ i] ;
kt:=i;
yes:=TRUE;
break;
end;
until Not yes;
end;

136

6. .

Var {Main}
i,j :Integer;
yes :Boolean;
begin {Main}
Assignff,'Eiler.in');
Reset (f);{ )
{ }
Read(f,n); ( }
Fst[l]:=0; ( }
for i:=l to n do begin
Read(f,Vtx[i]); ( }
Read(f,Nbr[i]); ( }
for j:=l to Nbr[i] do Read(f,Adj[Fst[i]+j]);
( }
Fst[i+1]:=Fst[i]+Nbr[i];(
}
end;
Close(f);
Assign(f, 'Eiler.out');
Rewrite(f); ( }
Init(yes);
if not yes then begin
WriteLn(f,' ');
WriteLn(f,'
!');
Close(f);
exit;
end;
Eiler;
Write(f,' 0=' ) ;
for i:=l to kz do Write(f,Vtx[z[i]]:3); WriteLn(f);
Close(f);
end. {Main}
6.6 , . 6.17.

. 6.17.

6.8.

137

6.6
Adj[x] . 6.17
Eiler.in. () ,

6.2.
Eiler.in . 6.17:
9
1
2
3
4
5
6
7
8
9

4
4
4
4
4
2
2
2
2

2
1
1
1
1
2
2
3
4

3
3
2
5
4
5
3
4
5

Eiler.out
:
Z=
R =
Z =
R=
Z =
0 =

1
1
1
5
1
1

2
2
6
2
2

3
3
2
3
3

1
1
7
1
1

4
4
3
4
4

5
5
8
5
5

1
1
4 9 5
6 2 7 3 8 4 9 5 1
6 2 7 3 8 4 9 5 1 .

Z, R . .

6.8.

. = (X, U, ) 0 = (X, U0, ),


(. 6.18).

. 6.18.

138

6. .

6.8.1. - 1 .
.
. , ,
( ). ,
, > 2, , .
. , . > 2, ,
, .
. , ,
, .
= 2 , . , ,
. . . , , .. 1
.
2 , ,
1.

. , .
.
, ?
, .
. = (X, U, ), X ,
U . & U ()
. ,
= (X, U0, ), , W(r0)= ^(). , 0 ,
, "*%

.
. () ()
.

6.8.

__

139

6.8.1.

= (X, U, ) ,

. ,
, . ,
\\ 1 .
.

. = {xl5 2,..., } = (X, U, )

1*1
, = (Xif ), X, = {,}, Ui = 0,
2,..., \\. , =(J T(
0 = (, 0,).
0

7} = 7} u TJ (Xt I = Xj vXj = U, i u 7) 7j,
,
=11^ . =[_)Tj = (X, U0, )
i

, \\ 1.
.
6.8.1. = (X, U, ) 0 = (X, U0, )
. :
1) V xi, x2 ^ 0;
2) 0 U \ U0,
.
. 1 , ..
0 , . 2 ,
, , .

140

6. .

6.8.2. = (X, U, ) , U (),


Tj = (Xj, Uj, ) ,
= Tj, ,
0 = (X, U0, ), / = 1,2,..., k k > 1.

= (, ) U \ /, 1
i

\. 0= (X, U, ), /, U{E},
, /,.
. . '0 = (,'0,) , /, i

,
, /, {}. 1 6.8.1,
- '0 .
'= (', ), , ' 1 ' Xi, .. ( /1 (, ) g A^,
/! (. 6.19). ,
() < (), /, U0 /,- U'0

. 6.19


/ Uj ,
', .. /,.
= (X, U0, ),
'0 ' '0. 0 ,
'. 0 *
''. , 0 .
, () < ( ), '0. 0 /, , 0,
.

6.8.

141


6.7.
, . Mark[x] X
Uit
. Mark[x,]
, X.
Mark[Xj] Uit .
U,
Uo.
6.7.
for Xj e Xdo Markfa] = i;
Sort(U)', { )

U0 = 0;

while \UJi<\X\- I do begin


(, ) U\ { win )
ifMark[x] Mark[y] then begin
U0 = U0 u {(, )}', { )
Z = Mark[y];
{ UxuUy)
for v 6 Xdo ifMark[v] = z then
Mark[v] = Mark[x]\
end;
U= U\{(x, )}; { min ]
end;
.
.
O(\U\2). 6.7 Ux Uy.
( 6.7)
0(\\2). , (\ |2) + | J7|2).

6.8,
6.7.

142

6. .

6.8.
Program HungryOstov; { . )
uses CRT,DOS;
Const
nVertex=50; { }
nRib=1000; ( }

TypeVertex=array[I..nVertex] of Integer;
TypeRib=array[1..nRib] of Integer;
Var
f
:Text;
( }
nX
:Integer;
{ }
nU
:Integer;
{ }
Mark :TypeVertex; { }
X
:TypeVertex; { }
U
:TypeRib;
{ }
nUo :Integer;
{ }
Uo
:TypeRib;
{ }
We
:TypeRib;
{ }
Wt
:LongInt;
{ }
Procedure Init; { }
Var
i,j,m :Integer;
begin
for i:=l to 2*nU do Uo[i]:=l;
for i:=l to 2*nU do
for j:=i+l to 2*nU do if U o [ j ] = l then
if U [ j ] = U [ i ] then U o [ j ] : = 0 ;
nX:=0;
for i:=l to 2*nU do
if Uo[i]=l then begin
nX:=nX+l;
X[nX]:=U[i];
end;
for i:=l to 2*nU do { }
for m:=l to nX do
if U [ i ] = X [ m ] then begin U [ i ] : = m ; break; end;
end;

Procedure Sort; { }
var
i,j,k :Integer;
w
:Integer;
begin
for i:=l to nU do
for j:=l to nU-i do
if We[j]>We[j+l] then begin

6.8.

143

w:=We[j]; We [j ] :=We [ j+1] ; We[j+l]:=w;


w:=U[2*j-l]; U[2*j-l] :=U [2* ( j+1) -1] ;
U[2*(j+l)-l] :=w;
w:=U[2*j]; U [2* j ] :=U [2* ( j+1) ] ; U [2* ( j+1) ] :=w;
end;
end;
Procedure Ostov; { }

Var
i,x,y,z : Integer;
sU
: Integer;
begin
for i : =1 to nX do Mark[i]:=i;
Sort; { }
nUo:=0; { Uo}
sU:=l; { U}
while nUo<nX-l do begin
x:=U[2*sU]; { }
y:=U[2*sU-l] ;
if Mark [x] OMark [] then begin
nUo:=nUo+l;
Uo [nUo] :=sU; { }
z:=Mark[y]; { Ux Uy}
for i:=l to nX do if Mark[i]=z then
Kark[i] :=Mark[x] ;
end;
sU:=sU+l; { (, ) U}
end;
end;
Var (Main)
i,j : Integer;
begin (Main)
Assign (f , ' Hungry. in' ) ;
Reset (f) ; { }
Read(f,nU); { }
for i;=l to nU do Read (f , U [2*i-l] ) ; {
}
for i:=l to nU do Read (f , U [2*i] ) ;
{
}
for i:=l to nU do Read (f ,We [i] ) ; { }
Close (f) ;
Assign (f , ' Hungry. out' ) ;
Rewrite (f); { }
Init ;
Sort ;
WriteLn(f, 'nU =',nU:3);
WriteLn(f , ' nX =',nX:3);

6. .

144

W r i t e ( f , ' X = ' ) ; f o r i:=l to nX do W r i t e ( f , X [ i ] : 3 ) ;


WriteLn(f); Write(f,'ul =');
for i:=l to nU do W r i t e ( f , X [ U [ 2 * i - l ] ] : 3 ) ;
WriteLn(f); Write(f,'u2 =');
for i:=l to nU do Write ( f , X [ U [ 2 * i ] ] : 3 ) ;
WriteLn(f); Write(f,'We =');
for i:=l to nU do Write ( f , We [i] : 3) ;WriteLri ( f ) ;
Ostov;
Write(f,'uol=');
for i:=l to nUo do Write(f,X[U[2*Uo[i]-1]]:3);
WriteLn(f); Write(f,'uo2=');
for i:=l to nUo do Write(f,X[U[2*Uo[i]]]:3);
WriteLn(f); Write(f,'Woe=');
for i:=l to nUo do Write(f,We[Uo[i]]:3); WriteLn(f);
Wt:=0;
for i:=l to nUo do Wt:=Wt+We[Uo[i]];
Write(f,'Bec=',Wt:3);
Close(f);
end. {Main}
, . 6.20, 6.8.

. 6. 20.

. 6.20 Hungry.in :

(12);
: ,
;

6.8.

145

.
12

7 7 7 7 7 7 1 2 3 4 5
1 2 3 4 5 6 2 3 4 5 6 1
1 4 9 16 25 36 20 15 3 17 28 23

Hungry.out :
nU = 12
= 7
= 7
ul = 7
u 2 = 1
We = 1
uol= 7
uo2= 1
Woe= 1
Bec= 57.

1
3
4
3
3
4
3

2
7
2
4
7
2
4

3 4 5 6
7 2 7 4 1 6 7 5 7
3 3 4 5 2 1 5 6 6
9 15 16 17 20 23 25 28 36
7 4 6
3 5 1
9 17 23

Hungry.out:
nU ;
;
X ;
(ul, u2) ;
We ;
(uol, uo2) ;
Woe ;
.

6.8.2.


,
.
1. 0
Xj.
2. , , (xj, x2)
0.
3. , , xl 2 3.

146

6. .

4. , 0. .
, 14 ,
. 6.9, = (X, U, ) We = [],
+. .
= (0> U0, ) Uo . = {1, 2,..., }. , ,
0. dist[x]
nprev[x], dist[x] *
prev[x] 0. dist[x]
prev[x]
0 .
. .
. ,
6.9.
= {1, 2,..., }; { }
= \\; { ]
v = rand(\, \\); { v X]
XQ - Mi { }
X=X\{v}; { v }
U0 = 0; { }
WT= 0; { ]
for x e Xdo begin
disfix] = We[x, v]; { v 0}
prev[x] = v; { (v, ), dist[x]}
end;
while \X0 \*nXdo begin
dist[v] = min dist[x]; { v }
xsX

6.8.

147

0 = 0 u {v}; { ]
X=X\{v]\ { ]
U0= U0^j {prev[v\, v}; {]
WT= WT+ dist[v\; { ]
{ dist[x] ]
forx e Xdo ifdist[x] > We[v, x] then begin
dist[x] = We[v, x];
prev[x] = v;
end,
end.
6.10, 6.9.
6.10.
Program NearOstov; { .
}
uses CRT,DOS;
Const
nVertex=50; { }
nRib=1000; { }

TypeVertex=array[I..nVertex] of Integer;
TypeRib=array[1..nRib] of Integer;
TypeWeight=array[1..nVertex,1..nVertex] of Integer;
Var
f
:Text;
{ }
nX
:Integer;
{ }
nXo :Integer;
{ }
nUo :Integer;
{ }
X
:TypeVertex; { }

:TypeVertex; { }
Uo
:TypeRib;
{ }
Prev :TypeVertex; { }
Dist :TypeRib;
{ }
We
:TypeWeight; { }
Wt
:LongInt;
{ }
Procedure minDist( Var v :Integer );{ v -
}
Var i,d :Integer;
begin
v:=X[l];

148

6. .

d:=Dist[v];
for i:=2 to nX do

if d>Dist[X[i]] then begin


v:=X[i];
d:=Dist[v];
end;

end;
Procedure newDist( v :Integer );{ dist[] }
Var i :Integer;
begin
for i:=l to nX do
if Dist[X[i]]>We[X[i] ,v] then begin
Dist[X[i]] :=We[X[i],v] ;
Prev[X[i]]:=v;
end;
end;
Procedure Ostov; ( )
Var i,nStop,v :Integer;
begin
nStop:=nX;
for i:=l to nX do X[i]:=i;
v:=l;
for i:=l to nX do begin
Dist[i]:=We[i,v];
Prev[i]:=v;
end;
nXo:=0; { Xo - }
nUo:=0; { Uo - }
nXo:=nXo+l;
Xo[nXo]:=X[v]; {Xo=Xo+v - v }
X[v]:=X[nX]; nX:=nX-l; { X=X\v - v X }
Wt:=0;
while nXoOnStop do begin
minDist(v);
nXo:=nXo+l;
Xo[nXo]:=v;
{Xo=Xo+v - v }
for i:=l to nX do { X=X\v - v X }
if X[i]=v then begin X[i]:=X[nX]; break; end;
nX:=nX-l;
nUo:=nUo+l;
Uo[2*nUo-l]:=Prev[v];{ Uo=Uo+(Prev[v],v) }

6.8.

149

Uo[2*nUo]:=v;
Wt:=Wt+Dist[v]; { }
newDist(v);
end;
end;
Var {Main}
i,j :Integer;
begin {Main}
Assign(f,'Near.in');
Reset(f);{ )
Read(f,nX); { }
for i:=l to nX do begin
for j : =i to nX do begin
Read(f,We[i,j]); { }
if We[i,j]=0 then We[i,j]:=$7fff; {+}
We[j,i]:=We[i,j];
end;
end;
Close(f);
Assign(f,'Near.out');
Rewrite(f); { }
nUo:=0;{ }
for i:=l to nX do
for j:=i+l to nX do begin
if We[i,j]=$7fff then continue;
nUo:=nUo+l;
Uo[2*nUo-l]:=i;
Uo[2*nUo]:=j;
end;
WriteLnff,'nU =',nUo:3);
WriteLn(f,'nX =',nX:3);
Write(f,'X =');for i:=l to nX do Write (f,i:3);
WriteLn(f); Write(f,'ul =');
for i:=l to nUo do Write(f,Uo[2*1-1]:3);
WriteLn(f); Write(f,'u2 =');
for i:=l to nUo do Write(f,Uo[2*i]:3);
WriteLn(f); Write(f,'We =');
for i:=l to nUo do Write(f,We[Uo[2*1-1],Uo[2*i]]:3);
WriteLn(f);
Ostov;
Write(f,'uol=');
for i:=l to nUo do Write(f,Uo[2*i-l]:3);
WriteLn(f); Writeff,'u62=');
for i:=l to nUo do Write(f,Uo[2*1]:3);WriteLn(f);

150

6. .

Write ( f , ' W o e = ' ) ;


for i:=l to nUo do W r i t e ( f , W e [ U o [ 2 * i - l ] , U o [ 2 * i ] ] : 3 ) ;
W r i t e L n ( f ) ; Wt:=0;
for i:=l to nUo do W t : = W t + W e [ U o [ 2 * 1 - 1 ] , U o [ 2 * i ] ] ;
Write(f,'Bec=',Wt:3);
Close(f);
end.{Main}

6.10 ,
. 6.20.
Near, in :
;
( ) .
7
0 20 0
0 15
0

0
0
3
0

0
0
0
17
0

23
0
0
0
28
0

1
4
9
16
25
36
0

Near, out
:
nU = 12
= 7
=
ul =
u 2=

1
1
2

2
1
6

3
1
7

4
2
3

5
2
7

6
3
4

7
3
7

We = 20 23

1 15

9 17 16 28 25 36

uol= 1 7
uo2= 7 2
Woe= 1 4
Bec= 57.

7
3
9

4
5

4
7

5
6

5
7

6
7

3 4 1
4 5 6
3 17 23

Near, out Hungry.out


6.8 (. .6.8.1).

6.9.

151

6.9.
.
.
, , ( ) ;

. , ,
.
/= (X, U, ) , U
() > 0. $ z (. 6.21).
.
.
w,y = co(w) = (,-, xj).
, XQ, , Xj XQ. . Xj XQ Xj, XQ ,. Xj OTXQ
Xj. ,
, . , z , .. XQ z.
XQ 0 ( ), \\ 1
().

.
.
1. ,, ,
(wy + ,), , ,
.
2. ,
.
.

152

6. .

.1+.2 ,
z . ,
XQ.
, . 6.21.

. 6.21.


.
xl

15

10

13

15

, ..
0. z XQ, .

6.11, = (X, U, ) We = [w,-,], +. Mark[x]
(TRUE) (FALSE) . Dist[x] . Prev[x] .

6.9.

153

6.11.
for x e X do begin
Mark[x] = FALSE;
Dist[xJ = oo;
end;
= ',
Mark[xQ\ = TRUE;
Dist[xQ] = 0;
while not Mark[z\ do begin
for x e X do
if not Mark[x] and dist[x] > dist\y] + w[y, z] then begin
dist[x] = dist\y] + w[y, x];
prev[x]=y;
end;
{ X }
dist\y] =
min
dist\x\
xsXand

Mark[x]=FALSE

Mark\y] = TRUE;
end.
Prev[x] , .
:
z, prev[z], prev\prev[z]], prev\prev\prev[z]]], ... , 0,
Dist[z] XQ z-
, , .
, while \\ 1 , ,
, 0(\ |). 0(1-^1 ).
, 0 , 6.11
while not Mark[z] do begin while
v not Mark[x] do begin.

.

6.12 Pascal'e, 6.11.

154

6. .

6.12.
Program Short; { }
uses CRT,DOS;
Const
nVertex=50; { }
Type
TypeMark=array[0..nVertex] of Boolean;
TypeDist=array[0..nVertex] of Longlnt;
TypePrev=array[0..nVertex] of Integer;
TypeWeight=array[0..nVertex,0..nVertex] of Integer;
Var
f
:Text;
{ }
nX
:Integer;
{ }
Mark :TypeMark; { }
Dist :TypeDist;
{
()}
Prev :TypePrev;
{ }
We
:TypeWeight;
{ }

:Integer;
{ }
z
:Integer;
{ }

:Integer; { }

Var
i,j, :Integer;
weight :Longlnt;
begin
Assign(f,'Short.in');
Reset(f);{ }
{ }
Read(f,xO); { }
Read(f,z); { }
Read(f,nX); { }
:=-1; (* ={,1,2,...,} - *)
for i:=0 to nX do begin
for j:=0 to nX do begin
Read(f,We[i,j]}; { }
if We[i,j]=0 then We[i,j]:=$7fff; {+}
end;
end;
Close(f);
Assign(f,'Short.out');
Rewrite(f); { }
for :=0 to nX do
Mark[x]:=FALSE;
Distfx]:=$7fffffff;

end;

begin

6.9.

155

:=; { }
Mark[]:=TRUE;
Dist[y]:=0;
while not Mark[z] do begin
{ ]
for x:=0 to nX do if not Markfx] and
( Dist[x]>DistCy]+We[y,x] ) then begin
Dist[x]:=Dist[y]+We[y,x];
Prev[x]:=y;
end;
{ }
weight:=$7fffffff;
for x:=0 to nX do if not Mark[x] then
if weight>Dist[x] then begin
weight:=Dist[x];
y:=x;
end;
Mark[y]:=TRUE;
end;
Write(f,' =');
x:=z;
while xOxO do begin
Write(f,x:2);
x:=Prev[x];
end;

WriteLn(f,x:2);
W r i t e L n ( f , ' = \ D i s t [ z ] ) ;
Close(f);
end.

6.12 , . 6.21.
Short.in :
^;
z',
;
[]
.

6. .

156
0
0
0
0
0
0
0

7
0
3
0
0
0
0

2
0
0
0
8
0
0

5
0
0
0
0

0
5
0
3
0

1
0

0
0
0
7
5
0
0

0
10
0
0
2
6
0

Shortcut
:
= 6 4 3 1 2 0
= 11.

6.10.

. = (X, U, )
:0 z (. 6.22). 0
, . z
, . U () > ,
() .

. 6.22.

. () > 0 , elf
:
/"()<() >()= >(),
(6.10.1)
, .. 0, * z',
UZ , ;
U~ , (. 6.22).

6.10.

157

. 6.22 , ,
. (6.10.1) , , , ( ).

() , z;

(*) , ^.
6.10.1. () = (0).
, [ ^()- ]>]()]=0, V e U
() + -.
6.10.1.

. X : 0 g A, z^A. U^
, .
.

() /

. 6.23.

() = ]() .
(/^
, .
(4) = ^ () , . ,
<=+
() < (), V w e U () < ().
6.10.2. () < ().
, . 6.23 , , , z. . , () < (), () < (), () < ().

158

6. .

6.10.1 .
, ..

max (( ) = ().
. .
1. . , XQ z s U, () = ().
.
1.1. . , : Vu e Uq(u) = 0.
1.2. XQ . ,
1.3. , 1.5.
1.3. , .
1.4.
1.2, $ z.
1.5. .
2. . , , . 6.24. , .
-2 Xl

+ 2

. 6.24.

2.1. XQ 0.
2.2. Xj ; , :,.
+/,
Xj-*y(+i), /',

/ <- ~0- : z , .

6:10.

159

2.3. z . , 0 z. , . 6.25.
, , $ z,
, ,
. 6.25.
-

1
1

+0
-*-
2

1
1

3
1

-2

1
2

+1

1
0
2

3
2
xl

. 6.25.

, () () ,
(). ( 2.1).
z. , z
, , , .. , z .
2.4. z . . 6.26. * . , ,
, . * = {xlt z} * , XQ < A*, z e *. , * *, *(*) = (*). , *
, *(*) z, .. *() = (*).
xl

. 6.26.

162

6. .

.
= (X, U, ) .
/ f/ ,
. . Q
, .
, Q, .
. , . ,
. (7) ,
,
() .
.
, , . .

((7).
,
. , .
(3(/) = 8.
6.11.1.
, , ,
(7) > 5(/) ()
.
. (=>) 7 U
, k 7,
, k u /
, 7 . 7
. (<=) 7 . k 7 /, k <u I
, , 7 .

6.11. ,

163

. / , .
.
, , .
. 6.31 .

4 4

. 6.31.

. , = (X, U, ) , () , .
, . ,
.
() . S = 0.
S -
.
S u {}, eS S.
S S {} ,
. . 6.32 , .
, :
{1,2,3} 3! , {3,4} {4,5} 2! .
& k\ . . 6.32 ,
. ( ), .

164

6. .

3}

{12}

(21}

(23|

(31}

{32}

{132}

{123}

{213}

{231}

{312}

{321}

{34}

{45}

{43}

{54}

. 6.32.

6.11.2. = (X, U, ) , S T(Sc X ).


S ,
, . {},
. 6.33, S.
Sv {} , S^j {}.
Su {v,-},
v g Adj[x] (. 6.33).
. 6.33

Su {v/}
(
5)

6.11.3. S ,
S S SB . Su{x} , , S {},
Ju{x}
.
6.13
.
CLIQUE : Nn D. S

6'. 11. ,

165

N /) ,
S, .. N<uD ,

S. N , S , ..
1

N= (x A]|(A:,J) e UVs - S S w {x} }.

6.13.
5=0; { }
N=X;
D = 0;
Z=X;

CLIQUE(N, D, Z); { }
Procedure CL1QUE(N, D, Z)
i/ TV D = 0 then S,
else ifN*0 then begin
x e N; { }
View(x); { }
{ ]
Z=Z\(x};Z=Z\Adj[x\while Z#0 do begin
veZ;
View(v); { }
Z e Z\{v};
end',
end;
end;
Procedure View(v) { }
N= N\{v};
S=S\{v};
D = Dv{v};
end;
CLIQUE x e N,
N S= Su{x},
View. , 6. 11. 2 6 . 11.3,
S= Su {v},
v ^ v g vl$[;c] v e Z.

166

6. .

Z ,
,
.
D CLIQUE
, S, ,
S .
D = { x z X}\(x,s) et/Vs eSu noddepeeoS u { x ) S ^S].
S X = (X, U, ) TVu D ,
S.
S ,

N= 0 Z) * 0 , ,
S, .

N* 0 , S,
. S u {},
N .
6.13, , N D,
, , .

6.14 Pascal'e, 6.13. ,
N, D, ZB
kN, nN, kD, nD, kZ, nZ, kN, kD, kZ
, N, D, Z, a nN, nD, nZ
.
6.14.
Program PgmClique; ( )
uses CRT, DOS;
Const
nVertex=100; { }
nAdjacent=1000; { }

TypeVertex=array [I . .nVertex] of Integer;

6.11. ,
TypeAdjacent=array[I..nAdjacent]

167
of Integer;

Var

f
m
Adj
Fst
Nbr

:Text;
{
:Integer;
{
:TypeAdjacent;{
:TypeVertex; {
:TypeVertex; {

}
}
}
}

}
Vtx :TypeVertex; { }
S
:TypeVertex; ( }
nS
:Integer;
{ S }
N
:TypeVertex; {
)
{kN,nN - N}
D
:TypeVertex; (
}
{kD,nD - D)
Z
:TypeVertex; { }
{kZ,nZ - 2}
Procedure PrintClique; FORWARD;
Procedure Subtract; x:Integer; Var kZ,nZ:Integer ); FORWARD;
Procedure Intersection( v,kM,nM:Integer; Var kMw,nMw:Integer; Var M:TypeVertex ); FORWARD;
Procedure View( v:Integer; Var kN,nN, kD,nD, kZ,nZ:Integer ); FORWARD;
Procedure Clique( kN,nN,kD,nD,kZ,nZ:Integer ); FORWARD;
Procedure Init( Var yes :Boolean );
{
}
( yes -
}
Var
i,j,k :Integer;
begin
for i:=l to m do
for j:=1 to Nbr[i] do begin
yes:=FALSE;
for k:=l to m do
if A d j [ F s t [ i ] + j ] = V t x [ k ] then begin
yes:=TRUE;
Adj[Fst[i]+j]:=k;
break;
end;

168

6. .
if not yes then exit;
end;

end;
Procedure PrintClique;
( }
Var

i :Integer;
begin
for i:=l to nS do Write (f,Vtx[S[i]]:3); WriteLn(f);
end;
Procedure Intersection( v,kM,nM:Integer;
Var kMw,nMw:Integer; Var M:TypeVertex ) ;
{ M*Adj[v] Adj[v] }
Var
i,j,k :Integer;
yes :Boolean;
begin
{kMw - M*Adj[v]}
{nMw - M*Adj[v]}
kMw:=kM+nM;
nMw:=0;

for i:=l to nM do
for j:=l to Nbr[v] do
if M[kM+i]=Adj[Fst[v]+j] then begin
nMw:=nMw+l;
M[kMw+nMw] :=M[kM+ i];
break;
end;

end;
Procedure Subtract( x:Integer; Var kZ,nZ:Integer );
(* Z=Z\{x} Z=Z\Adj[x] *)
Var
i,j,k :Integer;
yes :Boolean;
begin
(* Z=Z\{x} *)
for i:=l to nZ do
if Z[kZ+i]=x then begin
nZ:=nZ-l;
for k:=i to nZ do Z[kZ+k]:=Z[kZ+k+1];
break;
end;
(* Z=Z\Adj[x] *)

6.11. ,

169

for j:=l to Nbrfx] do


for i:=l to nZ do
if Z[kZ+i]=Adj[Fst[x]+j] then begin
nZ:=nZ-l;
for k:=i to nZ do Z[kZ+k]:=Z[kZ+k+1];
break;
end;
end;
Procedure Clique( kN,nN,kD,nD,kZ,nZ:Integer );
{ }
Var
i,j,x :Integer;
begin
if (nN=0) and (nD=0) then { }
PrintClique { )
else if nN<>0 then begin (
}
x:=N[kN+nN]; { N}
View(x,kN,nN,kD,nD,kZ,nZ); {
}
Subtract(x,kZ,nZ); (* Z=Z\{x} Z=Z\Adj[x] *)
while nZ<>0 do begin {
}
x:=Z[kZ+nZ];
View(x,kN,nN,kD,nD,kZ,nZ) ;
nZ:=nZ-l; (* Z=Z\{x} *)
end;
end;
end;
Procedure View(v:Integer; Var kN,nN,kD,nD,kZ,nZ:Integer);
{ } Var
i,k :Integer;
kNw,nNw :Integer;
kDw,nDw :Integer;
kZw,nZw :Integer;
begin
(* N=N\{v} *)
for i:=l to nN do
if N[kN+i]=v then begin
nN:=nN-l;
for k:=i to nN do N[kN+k]:=N[kN+k+1];
break;
end;

170

6. .

(* S=S+{v} *)
nS:=nS+l;
S[nS]:=v;
(* *)
Intersection(v,kN,nN,kNw,nNw,N); {N Adj[v]}
Intersection(v,kD,nD,kDw,nDw,D); {D Adj[v]}
(* Z=N *)
kZw:=kZ+nZ;
nZw:=nNw;
for i:=l to nNw do Z[kZw+i]:=N[kNw+i];
(* *)
Clique{kNw,nNw,kDw,nDw,kZw,nZw);
(* S=S\{v} *)
nS:=nS-l;
(* D=D+{v} *)
nD:=nD+l;
D[kD+nD]:=v;
end;

Var
kN,nN, kD,nD, kZ,nZ :Integer;
i,j :Integer;
yes :Boolean;
begin
Assign (f,'Clique.in');
Reset (f); { }
{ }
Read(f,m); { }
Fst[l]:=0; { }
for i:=l to m do begin
Read(f,Vtx[i]); { }
Read(f,Nbr[i]); { }
for j:=l to Nbr[i] do Read(f,Adj[Fst[i]+j]);
{ }
Fst[i+1]:=Fst[i]+Nbr[i]; {
}
end;
Close(f);
Assign(f,'Clique.out');
Rewrite(f); { }
Init(yes);
if not yes then begin
WriteLn(f,' !');
Close (f);
exit;
end;

6.11. ,

171

{ : S, D, N, Z}
nS:=0; (S - }
kD:=0; nD:=0; {D - }
kN:=0; nN:=m; {N - )
for i:=l to m do N[i]:=i;
kZ:=0; nZ:=m; {Z - }
for i:=l to m do Z[i]:=i;
Clique(kN,nN,kD,nD,kZ,nZ); {
}
Close (f);
end.

.
. .
. , , , . . . .
,
. ,
, .
. 6.34.
. 6.34

!*.

6.14
AdJ[x] CUque.in. () ,
6.2.
Clique.in . 6.34:
7
3 3

1 4 7

14

3 4 5 2

172

44
72
24
54
63

6. .

3 1 2 5
36
1 4 5 6
4 1 2 6
7 5 2

Clique.out
:
6
6
4
4
3

5
7
5
3
7

2
2
1

Clique.out - .6.34. ,

.

6.12. ,

,
.
, . . = (X, U0, ) = (X, U, ). , U0, . . U\U0, U0.

/ 0.
/ \\ 1 ,
/
\U\ \\ + 1 .

, : .
F= {Q, 2,..., |^|_|-|+1} ,
, , U.
/ ((... (, ,-, )...) , ),
,
Cq = { | zCp uC ? }.

6.12. ,

173

, . 6.35 ,
. ({, 2, 5, 3 )
1 3 4 (XL 2, 4, /) 1 2 . ,

.

\2

. 6.35. ,


;
. ,
,
.
, ,
. 6.15, F= {Q, 2,..., ^^^}
= (X, U, ).
6.16.
6.15.
for v <= X do Mark[v] = 0; { }
count - 0;
jC= 0; { }
- 0; { }
for v 6 X do if Mark[v] = 0 then begin

174 _ 6. .

Cycle(v, 0);
= - 1;
end',
Procedure Cycle(x, )
count= count + 1;
Mark[x] = count; { }
for v s Adj[x] do begin
nC=nC+ 1;
C[n C] = v; { }
ifMark[v] = 0 then Cycle(v, x)
else ifMark[v] < Mark[x] v * then begin
jC=jC+ 1; { (, v), }
WriteCycle(v, , nC); { ]
end;
nC=nC - 1; { }
end;
end;
Procedure WriteCycle(x, , )
print jC; { ]
repeat
print C[nC\; { ]
= - 1;
until C[nC\ =x;
end.
6. 16.

Program GraphCycle ; ( )
uses CRT, DOS;
Const
nVertex=100; { }
nAdjacent=1000; ( )

TypeVertex=array [I . .nVertex] of Integer;


TypeAdjacent=array [1 . .nAdjacent] of Integer;
Var

f
n
nC

:Text;
: Integer;
: Integer;

. { )
{ }
{ )

6.12. ,

175

Adj
Fst
Nbr

:TypeAdjacent; { }
:TypeVertex; { }
:TypeVertex; {
}
Vtx :TypeVertex; { }
Mark :TypeVertex; { }

:TypeVertex; { }

:TypeVertex; {
}
jC
:Integer;
{ }
count:Integer;
{ }

Procedure Init( var yes :Boolean );


{ }
{ }
{ yes - }
Var
i,j,m :Integer;
begin
for i:=1 to n do
for j:=l to Nbr[i] do begin
yes:=FALSE;
for m:=l to n do
if Adj[Fst[i]+j]=Vtx[m] then begin
yes:=TRUE;
Adj[Fst[i]+j]:=m;
break;
end;
if not yes then exit/end;
end;
Procedure PrintCycle( x:Integer; var :TypeVertex;
nC:Integer); { }
begin

Write (f,jC,'')');

repeat
Write(f,Vtx[C[nC] ] :3) ;
nC:=nC-l;
until C[nC]=x;
Writeln(f);
end;
Procedure Cycle( x,:Integer );
Var
i,v -.Integer;
begin

178

6. .

6.13.1.

. = (X, U, ) .
-(,)& U ,
.
. ( ) . , , , , .

. = (, ) s i/ ( , ) , ,
, .
= / 1 2 >

(6.13,1)

/\ 2 = 0, /\ , 2 .
6.13.1. = (, ) U
, .
. (=>) , . , , (6.13.1) ,
: . (<=) = (,
) , .. ,
. .
. , 0 - , 1; 2,.-., Ck, 0 Cj, * Ck .

, . 6.36.

. 6.36. -

6.13.2. - (. .6.4) = (X, U, ). 6.37


.

6.13.

179

. 6.37. (^) - .
/~() .
/""(,/) s (

. ,
, L(x), . ,
,
. ,
, , ,
.
. (L), L, .
6.13.3.
(1).
1. f(L) , .. -
/ L, ().
2. , L\ L2,
L^ Z,2
. L{ L2 . , , .
3. P(L) . (, )
. , . , , , L ,
(, ) L. L
, , (, ) L,

180

6. .

, , L . , (, ) .
4. () . , (), ,
.

6.13.2.
. = (X, U, ) .
, v e U ,
{,
2,..., Ck, e C1; v e Ck, ,,
Ci+i , , . ,
. 6.38.

. 6.38. , v

. , e U, (*),
, . L , . .
6.13.1.
, ,
.
(. 6.38).
6.13.2. (, ) ,
, e Lb , (, ) ().
. ,
, (, ), ().

6.13.

181

, ,
(, ). , Lb, / ()
Q(x, ), , .
(, ) u Q(x, ) . 6.13.1,
, ,
(, ) (Lb), .
6.13.4. 6.13.2 , ()
. ,
,
, Lb,
(Lb).

(. 6.39). .
6.13.5. Lb
, - , (L ) . , Lb L, L , (L)

)=

(6.13.2)

.
. = (X, U, ) <= ( ),
(. 6.40)
=((2),

V=V^V2,

V^V2 = x.

(6.13.3)

. 6.40

6.13.6. () , - .
(6.13.2) (L)
( ) , (L) ()
, . 6.41,

6. .

182


.

. (6.13.2)
()=[_)(1^)

(. 6.37):
L. '" (. 6.41)
b
r(L k).

. 6.41

6.13.3.
. , ;
.
k

. 6.42. (); (); (), ()


(d); : b, f, j, i

, (. 6.40)
, .
,
. ,
. -

6.13.

183

. ,
, , , () .
. 6.42
( ).
.

= (X, U, ). , . 6.43, ,
rt, i = 1,6, Xj, j = 1,4.

. 6.43.

, , s e 2, 2 /i, x t . , /\ ,
Xj. /\ ,
^
. , ,
TI 5, ^ 4, 6,
2, /5 6. ,
6 5 Jc4 6 .
5 5. , , , , ( ). ,
, .

6.17. Mark[x]
-

184

6. .

.
. ,
. Mark[x],
. . 6.44 , w
.

w.
, ,
. 6.44
, w.
, (, w)
, , , Mark[w]
(z, x). , ( ),
. , .
Virtual[x] X,
Mark\y], ,
jc .

6.17.
count = 0;
Stack =0;
for v Xdo Mark[v] = 0; { ]
for v&Xdo ifMark[v] = 0 then Block(v, 0);
Procedure Block(x, w)
count= count+ 1;
Mark[x] = count; { }
Virtual[x] = count; { }
for v e Adj[x]X do
ifMark[v] = 0 then begin
Stack = Stack u (x, v);

6.14.

185

Block(v, x);
Virtual[x]=rmn(Virtual[x],
Virtual[v\);
if Virtual[v] > Virtual[x] then begin
,
. .
, (, v).
end,
end',
else if Mark[v\ < Mark[x] and v*w then begin
{ (x, v) }
Stack = Stack (, v);
Virtual[x] =rmn(Virtual[x], Virtual[v]);
end;
end.

6.14.

. = (X, U, ) ,

Vb V2 ,
= FJ V2 Fj \ V2 = 0.
= (V\ V2, U, ).
. 6.45
.
.

6.14.1.

6.14.1. = (X, U, )
, .
. (=>) , . (<=)
2>...,. Fk = (Xk, Uk, ) Xk
. Xk Vki Vk2, Vkl , ; Vk2 , , Vk2. Vkl Vk2 . , , b

186

6. .

, Vkl , Vk2, ' ,


y2t =r^rrzn
, . /1; 2,...,, v ;
. . 6.46 Vkl Vk2 . 6.46
F, = 1
k2

6.14.2.

. .
= ( 1 < V2, U, ) U, . s
.
_
,

, . 6.47, - h - ^ -2
*
n = {(si, I), (s2, 2)}, n = {(s3, 1), (s2, 2)} ..
. 6.47
. ,
.

6.14.3.

/= ( F| u V2, U, ) . ^ J^ 2 V2 (.
6.48). ,
/" , .
, . al e \
MJ = (a{, v2n) , ^ V2x. = (^^..
_1:_1) ,
2 2.
_ .48

6.14.

187

, ,
. , ,
rcj, 2,..., _1 w b 2,..., _ .
, , . , .
. = (Fj u V2, U, ), Vl = {sb
s2,..., s6} V2 = {1, 2,..., 6}. V{ 2 : st -> {4}, s:2 -> {1, 6}, . -> {4, 5, 6}, j4 -> {1, 3), ss -> {2},
,6 -> {1, 3}. .
, jj e F! j & V2 jj. . 6.49 = {(s{, 4), (s2, I), (s3, 5), (s4, 3), (ss, 2)}, || = 5.
s6 6 . , .
>
FJ V2
> F2 FJ. , s6
1,3}
, s6 1
3, {1,3}
>{s2,s4} , 1
6 4
3
s2 J4- s6. ,
s6, : s6
{1,3}
>{s2,s^}
{16}. , 6 2, s6,
. 6
s6 , , .
6 .

: 6
>s2
>1
>s6. , (s2, 1)
(6, s2), (I, s6).
. 6.49. (j1} 4),
(s3, 5), (j4, 3), (s5, 2), (s2, 6), (> 1) || = 6.

188

6. .

6.14.2 .
= ( Fj u V2, U, ) .

(*)

=" i

= { V2 & F, (, ) V) V2.

. (. 6.50).
: V2
> Vl V2 V{
.
, : V{
>2

. 6.50.

FJ V2
U . < Z
(. 6.50) , .
. ->
7i(A(ra)) K! .
: ^(7 ) ^ .. ,

(11 )7t .
, , . , :
\\ = \\,
.


u A = . ,

(*) , .. (/ ) = |Fj|
- (!# | - |5 1). | | = |( )\ = | <4)| = || , , | Fj| - (|5 1 - |5 1) = | KJ - (| | + | - |) = | ?i| - | | = ().

6.14.

189

, \/ FJ (*)
: () < \{\ (\\ ||).
, , (*) .
AI =\(>>), = ( ) Uv4j. , VAlc ( r\Ai)
\^ < \&Ai\,
F!\(CQ n FJ) . ,
\\ = | \ + \!\ < |< | + \{\ < | | + |A/4j| < | + |/4| \\ \ < \>.

: () = |Fj| || < \V^ (\\ ||). .

6.14.4.
: Sl = {2, 3}, S2 = {I, 2, 4}, 53 = {1, 2, 5},
,4 = {3, 4, 5}, 1% = {3,4, 5}. ^, 2, 3, , 5, Xj e Sf, i = 1,2,..., 5. ! = 2,
2 = 1, 3 = 5, jc4 = 3, 5 = 4. 7} = {1, 2},
2 = {1, 2}, = {1, 2}, 4 = {3,4, 5}, 5 = {3, 4, 5}, .
. 5= {1, 2,..., }.
M(S) S{, S2,..., Sn S. , M(S) ,
/' = 1, 2,..., xt e St.

6.14.5.

= (F! uF 2 , /, ),
. M(S) = {S{, S2,..., Sn} S^ S2,..., Sn S. Si, S2,..., Sn V\ ,

V2 (. 6.51).
- 6-51
6.14.1. F=(Vl\jV2, ,), M(S) = (S^, S2,..., Sn}, ,
M(S) . ( ,
).

190

6. .

6.14.3 .
. M(S) = {Sb S2,..., Sn}
, {., ,Sj ,...,Sj } M(S) k
(J Sj >k, ..
k k.
. (=>)
. St . M(S) , S{.,

,
(<=) = (Fj u^2, U, ) , M(S) = {S\, S2,..., Sn}. ,
, . 6.14.1 . 6.14.2 ,
(/) = |Fj|
-(|| -||), . = { V2 \ FJ (, ) V} F2. A = {St ,Si2,...,St }, \A\ = k
k

= (J Si : .. \\ > k. , VA FJ
7=1
\\ - ^ 0. , n(r)=|K 1 |-max(M-|A4)^|Ki|.
< |Fi|, , () = \V^ = ( ).

6.14.6.
, . .
. ,
. . ,
. ay /- - -

6.14.

191

. , .
. . /- '- . .
6.14.4 .
= [\, i,j= \,n .
X(
* /=i

(6.14.1)

mmHj>,+v,|

i+'^ft

,tl

(6.14.2)

, v,- ,
ut + Vj>av>

V/,y=l7ii.

(6.14.3)

(6. 14.2) ,

. .
/ 1 , {1, 2,..., }. u, + v, > a,j, Vi,j= 1, , ,
j = , + =,-. . (6.14.1) (6.14.2).

i=l

y=l

1=1

;=1

=1

/=1

, (6. 14.1) (6.14.2). , ,


, v, , (6.14.1) (6.14.2)
.
0. ; v,, r + v,> ay, V/, j = 1, . v,- = 0 ui = max a^ /- ; (6.14.3) , +Vj =maxOj, >o,y
. . 6.52 4
, , v,-.

192

6. .

I
2
3
4

V]

V2

3
1
6
6
0

4
4
5
4
0

2
3
2
5
0

V4
1

3
5
5
0

4
4
6
6

. 6.52.

1. v,-, j= l,n
/ = 1, , , + v, > ,-,
, + v,- = ,-,.
/ = 1,. . 6.53 .
V]

1/1

1/4

V3

V4

4
4
6
6

2
3

V2
*

*
*

. 6.53.
2. / = 1, -

^ ^ = {2}, S2 = {2}, ^3 = , ^4 = {!}


Sh i= l,n
: \ Sltj2 e S2,...,jn e Sn, ^, /2,...,7 /"
"

. =

72 JnJ

, +v_,- =, + =. , , .
3. , S\ , S2, . . . , Sn , . . , . .
, S^ uSi2u...uSik <k.

ju u

64! = 2 < 4. ;* v j ,
* =,1 -1, *2 = / 2 -1,..., M,*t =ii /t -1
vj =v y +1, E.S,-

193

6.14.

, v, . . . 6.54 * v).
"1
_"2__^

-J4

V]

V2

V3

V4

3
1
6
6

4
4
5
4

2
3
2
5

3
5
5

0
1

0
1

0
0

0
0

4
4
6
6

3
3
5
5

. 6.54. ' *VI

V2
*
*

V3

V4

0
1

0
0

0
0

4
4
6
6

3
3
5
5

. 6.55. * v'j

saMeHejnepeMeHHbix ut + Vj > Ojj, V/,7 = 1, . , :


l.jeS^ u Sj2v...vSik, * +v* =( -l) + (Vj +1)=, +v} >av.
2. j % Sj <uSi2 u...u Sj , , v* =Vj , + v,- > e&-
- + Vj>
V> a+ 1. * +v* =(, -l) + v^- >fly +1-1=.
=t <k, (6.14.2)
f ui1,,

k t. 2,

* v j , , 2
3 . (6.14.2)

^Uj '+ ^Vj k t ,


, , .
72697

194

6. .

. Uj v,- 1 . ,
, v, , _ :
2,
l^i u S2 u S3 u 5*4! = / = 2 k = 4. 2.
. 6.54, 6.55.
S{ = {2}, S2 = {2, 3,4}, S3 = {I, 4},
5*4 = {1, 3,4}. .
,
, 4
= ( ! uF2, U, ), F, = , S2, S3, SJ, F2 = {1, 2, 3, 4},
S{ -> {2}, S2 -> {2, 3, 4}, S3 -> {1, 4}, S4 -> (1, 3, 4}. ,
, :
, = {(Si, 2), (S2, 3), (5, 1), (,, 4)},
2 = {, 2), (5-2, 3), (5, 4), (,, 1)},
3 = {, 2), (S2, 4), (3, 1), . 3)}.
, :
'1 2 3 4^1
_(1 234}
_(1 2 3 4
3
3 1 4/ 2-[ 2 3 4 1/ " ~ U 4 1 3 j "

a J 2 + 23 + 31 + 44 = 1^-

6.15.
= (X, U, ) . / k-pac,
k ()
2,..., Ck ,
X=\JC,, , 7 =0 /*./

(6.15.1)

, , .. / (. 6.56). (6.15.1) k- .
k ,
. , .

6.15.


= (-0
(6.15.1) .

.
15.1.
= (X, U, ) 1^1 =
= n.
,, / = \,
(6.15.1)
, |CJ = 1, /' = 1,.

195

6 56

15.2. = (X, U, )
() k ,
%() k.
. (=^>) {1; 2,..., xk} e " . (6.15.1) : 2,..., Ck, , ,. ,
(6.15.1) . _ X
{xi,x2,...,xk\. Xj, / = 1,: ,- ,,
, k + 1 . Cj. , %() = k.
(<=) () = k. , /" k. : = , .
15.3. /= (X, U, )
, () = 2.
15.4. 2,
.
6.15.1. ()
%() =(, U, ), \\ =
() ()>.
(6.15.2)
. (6.15.1) , . () ,

196

6. .
1

|,|< P C / ) . ,

. .
6.57 (6.15.1)
, ,_.
_
. 6.57
() = 3.
. /
. , %() < 1+ 1.
. , -)(_()>1 + 2.
15.2 , () / + 2 .
/ + 2 / + 1.
,
/. ,

6.16. ,
I. = (X, U, ) . d(x, ) , e X. d(F) = maxd(x,y) .
. X .
r(x) =maxd(x,y)
"
.
III. () =minr(x).

. z X, r(z) = (),
.
. . 6.58 , .
. d(f) =max.d(x,y) =
= 3. !(*!>= 3, ( 2 ) = 2, f ( * 3 ) = 3,

(*4) = 2, (5) = 3, (*6) = 2. , () =min/-(x) = 2.


"

: 2, 4) 6.

7.1.

1.
2.
3.
4.

5.

. G ( ) , :
Va,b &G3c &G-b = .
\fa,b,c eC a-(b-c)=(a-b)-c .
3le<=G\/aeG e-a=a-e=a .
V f l e C r B l a " 1 &G -~1 =~1 -=
.
. , :
Va,b &G a-b =b- .


1. GI = { | 2} , Z
. , 0 ;
"1 = (-) Gv
2. GI = {In | Z} .
3. G3 = {2 | Z} .
4. <74 ,
, .
5. 5
.
6. G6 = {1, 1} .
7. G7 ( ).
8. G8 ( ).

198

7. .

9. G<) = Sm ()
( Sm, . .7.6).

1.
2.
3.

. Hc,G G,
,
G, .. // 14. , , : G2 Glt G5 G4, G7 G8.
7.1.1. G
Va,b ab~l . , . .
. .
. ,
~1 .
.
, ~1 ~ .
. a, b , b~l . ,
(b~l)~l ab .

7.2.

. Gl G2 /:GI - G2, : \/a,b sG{


f(a b) =/() /(), GI,
G2. / , /
.


1. .
\ ^ G{, /^) = 2 G2 G2. , VoeG./a) =.AaM<?i) =MM<0, ) =
) =) =)). \2 (?2 ) =
, [) = ^2 2. .
GI, "1) = ())"1. ,) ""1) ="1)) =
= <?2, ^"1) ="1) =,) = ^) =~1)),
) = 2. 3!() 2 )^^)-1 = <)') = 2. , ') = ()) !.

7.3.

199

. /
Im/= {2 e G2 \ , Gt 2 =/(,)} G2.

. /
/= {GI G! |/(0l) = 2 6 G2} ?!.

7.2.1. Im/c G2 .
. () .
1. . Va2,b2 Im/ 3flj,ii Gj /(^ = 2 A/(&J) = 2.
22 =/(fli)/(*i) =/(^1) Im/
2. . 2 =f(e{) Im/
3. . V 2 Im/ 3aj e Gj
/( fll ) = 2. 21 =(/(! ))-! ^/(flf 1 ) elm/.
7.2.2. / Gt .
. () .
1. . Vflj,^ / /(a^j) =f(a^)f(b^ = e2e2 = 2. , fljij /
2. . /Xej) = 2, ,
el /
3. .
Vfl l / /(or1) = (/(ai))"1 ^e^1 =2

7.3.

. = {, h\, H2,..., /J m _i}


G. gH= {ge, ghb gh2,..., gA m _i}, g e G,
G .
7.3.1. G, V/z
hH=H.
. - {, 2,..., hm_l]. Vhk hhk
- , . ,
hk = ehk = (hh~l)hk = h(h~lhk) , .
, = .
7.3.2. G.
0, i#= ft-ff, gb g2 e G.

200

7.

. glHr>g2H, 1 ; 2 ,
t = gj/j) = g2fi2. = (gihl)H=
= )#= g^H) = (2), = &.
7.3.3. G, V# e G
. ,
gff . 3Ai * 2 ,
ghi = gh2. g l(gh{) =g I(gh2) (g"V)^i = (glg)h2,
A! = A 2 > .
7.3.4. G , .. G = g\Hv g2Hu...
&, &, #2, . . . , gs ; #, n gfl = 0, ft # ft.
. <?={* ,# ,.># } ,
G=gk H<ugk H^j...(jgk H. ' 7. 3.,2 ,

7.3.1 . G
\G \ = || \G : |, \G : \
, G.
. 7.3.4
G = g1Hvg2Hv...ugsH, gfHr\g:H=0 ft*ft.
/.. Vft \gjH \ = \\, \G\ = \glHvg2H<u...vgsH\ =
= \S\H\ + \g2H\ + ... + |&| = s . , \G \ = || \G : H\,

. G . g e G
(g - e) k , gk = e.
7.3. L G g e G
k. = {g, #,..., g = e} , a g .
7.3.2. | G \ ^ e G. ( 7. 3.1 7.3.1).
7.3.3.
().
7.3.2. .

7.3.

201

. G G G . ,
g,
k
k
, g . , g 7
. , ^ , /* /
k. d = (I, k) ,
v, k + I v = d (. . 8.1).
, d
h
g = (g*)"(gV = & '. d < k, k
k
g . , g (
7.3.4.
2
G={g,g ,...,g" = e} () {1,2.,..., 1} .
. {1,2,..., 1} (, ) = 1 (.
.8.1), .. run . , (gr)k = fk- k<n,ior-k = n- / t, g. k = t ,
k, (, ) = 1.
k < . , \\ = .
(, ) = s s > 1, .. /= s = s q,
(, q) = 1. (/)" = (/ = *4 = tf9? = G?Y = # = ,
| /1 = q < . , | /1 q, (jf)9 = (/)* = , k < q,
r-k = n-t, #. ,
/&= f, s-p-k = s-q-t,p-k=q-t , q k,
.. (, q) - 1. k < q.
. G
, :
Vg G gH= Hg.
7.3.5. G
. G/H. G = glH<ug2H...
u gsffna , .. G/H=
= {g{H, g2H,..., gsH}.

202

7.

. .
1. . ^& G/H SlH- g2H=gl(Hg2)H=gi(g2H)H=
= 1() = (gig-^ff 6 G/H.
.
2. . (eH)(gH) =
= (gH)(eH) = (eg)H=gH, = G/H.
3. . (gH)(g~lH) =
= (g"lH)(gH) = (&= , g~lH G/
gH G/H.
7.3.3. G

/:<?- G/H, VgzG /(g) = gH,


, , G/H .
. : /(^ -g2)=(gi -giW = ( g l H ) ( g - i H ) = f ( g l ) f ( g 2 ) .
G/H ,
/= {(?|/() = }.
VA s /() = = , / ,
Vg g /(g) = #* . , gH= H, , gh = e g=h~ e ,
g g . , / , /= .
7.3.4. .
. /: G -> AT, G, AT ,/ . /= { e G|/(/J) = . = /
. , V e G gH= Eg, .. .
S= {g e G \f(g) = k e , k . , S-gH, geS
. gr 1, f (g\g~l) =
= e.
=f(Si i ) f ( g ~ = kk~ = e /) =/Gf =
n g ^ g^Hg ^^ , S^gHn
egeS.C , & f(gh) =f(g)f(ti) =f(g)e = fc.
gh <=S ^ S. , Hg^S.
, gH= S= Hg, .. .

7.4. ()

__

203

7.4. ()

.
Gi G2, .. G = G{ x G2,
:
1. Gj n G2 = e.
2. g G g = gig2... gk, g, &^ G2.
3. ^ eGj Hg r 2 &G2, g^g^ =g^g^.

B n a e g = g g , rae
eG
g i 2 (72. 7.4.1 , .
7.4.1. G Glt G2 ,
Gi n G2 = . , g^g2 =g'lg'2,
gl =g\ Hg 2 =g;>> ^,^1 eGj ^2,^2 ?2.
. , g^g2 =g[g'2> ^"1^^ =
=21S>2 =e< T-K- Glr\G2 = e. , gl =g\ g2 =g'2.
7.4.1. G GI G2 ,
:
1. GI \ G2 = .
2. G g = gift &. g, e Gl u G2.
3. G! G2 .
. (=>) , G
GI G2, 13
.
(<=) , gj e G1! g2 e G2, gjg2 =
= g2g!. g!g2 e g^G2 g!G2 = G^, gtg2 e G^,
gig2 =8281- gjg2 e G{g2 Glg2 = g2Gl, gjg2 e g2G!1 ,
, gjg2 =g 2 gj. , g{g2 =g'2gi =g2g[, GI n G2 = e,
7.4.1 , g2 =g2 gj =gl. ,
S\S2 = 8281-

204 _

7. .

7.4. 1. G 1

\\ = " % P^ > R Pi,P2>--->Pk ~~ . () = { G \ || =}, ,


G,
.
7.4.2. G
A(p^,
(),..., A(pk), \G\ = ^^ ...pakk .

\G\ = *12 2 />* , \G \ = , .. () = G. \G\=pag^, (p,q) = 1.
, G G = () A(q).
.
1. () r\A(q) = . , () A(q)
* , | jc | = | \ = (, = <, (, q) = 1.
2. , G
= z, (), z A(q). | \
| ^^'^.., < 2 <.( 1 ,# 2 )=1
, *"1 -m+q^1 -n =1 (. .8.1
), , . ' '+9 2 " =
= z, ^ =xq 2 '" z = ' ', ' =[ lq ] =
z ?"2 =1 'g 2 J = . , ^ = , | \ N. () A(q).
l<k, .. ||= ^^1 ?"'
\G\ = " ' %2 . . . ^k , G=-A(pl, p2,..., Pk-i)*A(pk), ( 2,..., ^) =
= { G | \\=^22 ---\^ }, , ^ ,,
|(7| =paq^. : A(pk) , ({,
~~> Pk-i) ; .

7.4. ()

205

7.4.2.

() () = {\ \ \ = } | () \ = ", ; .
. 2

. 1 ={, ,..., =}()


ai

\A{\=p . (. 7.3.1) \()\ = \{\ \()/^, ()/ = {^,


2,..., xkA} . ,
p
\/XjA A(p)/Ai (XjA) * = , , () = ()/{
,
2 () , ..
2
\()\ = \)\ \2\ \()/2\, \2\ = . () , ,
\()\ = \\\ \2\ ... \\, | ()\ =
7.4.2. () (),
()
| \ -" , ()/ ,
()/ | \ =, .. " = =,
| \ =.
. " =, " , ()/. , = -aCl'p , () = 1 < . = ' , " = zp I ]

=( zp )

= zp" =e ^ =. z ,
^+- _ j | \ =", | \ <". +"'?<" < .

fl

" = zp -zp =\ZP

6-IX \

,a

^^^^ " ^ " = [ (~1)* = . ,


=yz~l , | yl \ =.

206

7.

7.4.3. ()
. () = { G\ \ \ =/} \ ( ) \ =/, ) =(/' )
). . .( ), (' ) <
) = , Xj < 2 < ... < ^ + + ... +*=*.
. = 1 , .. () () \\ =, , . , / ^4 ()
\\ =. ()/ = (^, ^,..., /}. | ()/ \ <", .. | () \ = \ \ - \ ()/ \.

A(p)/A = C(pai)xC(pa*)x...xC(pa"). , zC(p"' : )
. 7.4.2 ,
, ^,- | yt \ = \ , | , = . , ()/ = z'llzt21 ---^ ,
=y'iy' ...'^, 0 </,<,. () ={ ^jx-^A u...ux^,
() =[122 '^'
,
.
, () = (^1 )( 2 )...( )
.
. = 1 () = () .
k < . ,
".
() =(/' ) (/2 )... C(pftl ), ! < 2 < ... < , . ,
\A(p)\ = pKi -:..- =/J P l -p^2 -...-JpP' =pn.


)()()...()
-?]
2

)()>).->).

7.5.

207

() [()] = {? \ ()}.
:
~l)

(*)

- ),
2

(**)
a

x * ,...,x" =e}.
p

| [A(p)] | < | A(p) | , , (*) (**) , .. 11 =


/2 = 2,.", = ( 2 , h = t2, , nm-tl = l-t2 = /. .
. G | G \ = 42.
42 = 2 3 7, G= (2) (3) (7).
. G | G \ = 4.
4 = 22,
G = (4) G = (2) (2)
G = {, 2, 3, 4 = } G = {, , , ] =
= {,2 = } {, 2 = }.

7.5.

. G . HcG
^-, \\ =.
. /7- ,

G.
7,5.1 (). G
\G\ = P^Pipakk, , .
1. pf G.
2. / G .
3. , .. , , t G, = tPt 1.
4. / k+l, ; .
2
1
. G \G \ = 28 = 2 7 , , \ ^ \ = 4 2, \ \ = 1.

208

7. .

7.6.
S .
S Sm .
, S
1
{1, 2,..., /?}. : 5 - S =

f 1

"'

V ! 2 - /

, = (/) / = 1,/. ( ) ()(/) = ((/)).


1
:
, = ~ ; : : ] = , 5 ' 7l
\-> * *J
\^

=( J5 ? ~ ] =( ~J ~ ?). , - ^/
v^ v
Sm ()
> 3. = \ . () (\ 9

= | f " '
= = . =^

> ^

i
9

...

Hi "2 KmJ

I | ... . |

-1

= / 2 w "' I ,
U /

-1

= = .

7.6.1. ^ 2
.

. , /2,---,
/^, (/!) = /2, (/2) = /,...,(/ ) = /i
, : (/ /2,..., /J.
. , ' /2,..., 4 (
), . , (/1) = /2, 2^) = ((/!)) = (/2) = /3,
rc^Oi) = '*> , *('1) = 'i- : (/ /2,...,

7.6.

209

. I ~ j 4 5 6 7 3 )=^' ^' ^ 4> ^' ^' ^ ~~ A1 .


. ,
.
, (1, 2, 3, 5, 9) (7, 8) .
7.6.1. Sm .
. Sm i,j e S. /
i~j, ' = *(/) k.
S. ^ S= Sl^j S2 u...u Sr.
/ e 51 S,, S, / : S, = {/, (/), 2 (/),.. ..*'"1 (/')}, k,
St. ., -. S, /, , ={/,,(/,), 2 (/,),...,n k '~ l (i,)}.
, S,,
,,
= ^.-.,..
1. , = (/',) 1,
.
= 12... .
2. = 12...
. ,
= . 1 ^...^,{ 1 2 ... }={ 1 , 2 ) ..., }.
.^ 2 3 4 5 ) = (1345)(2)(6)41345),
32154
. (d)
, . , d
, d .

210

7. .

+1, - ,

sgn(rc) = <
[-1, - ,
d

Sm, sgn(rc) = (~l) .


, I i ? 5 4 6 ] = (132) (45)
d= 5 - 2 = 3, , .
. 2
= (). d = 2- 1 = 1
.
7. 6.2. 5^ = () .
. = (/1/2.../)(/2-")---(^2---' . = ().
:
1. a , .
2. , g .
3. g , .

4. , , .
5. , , .
k ; /
. d(n) = k- I.
1. 0 , $. , = (/^../^(/^...^...(^^.../^(). </() = ( + 2) - (/+ 1) = - /+ 1.
2. , g . , iv = .
= (/2.../)(/2...)...(/1/2...() = (/2.../^)(/2-)-(^2- </() = (&+!) - / = & - / + ! .
3. a g , , .
4. , , .
= (/2...//+2.../)(/'1/2..:/;)...(/1/2...//,)() =

?() =k-(l +!) = & - / - ! .


5. , , .
= (a/2.../r)(py2...^)...(/1/2.../;,)(ap) = (/.../^...;;)...^.../,).
?() = & - ( / - !) = & - / + ! .

7.6.

211

, () = (-1)*~/! =
= (-1)L (-!)*"'= -sgn(u) .
7.6.3. Sm ,
.
. = (/i/2V)(/i/2)(/i(2^) ~ . (/Y/2-'/) = ('i^X'i's)('ifs)-
= 12..., ., .
7.6.2 sgn(Ti) = 8(12...) =
= sgn(t1T2...Vl)-(-l) = sgn(T1T2...Tn_2)-(-l)(-l) ^
, sgn(n) - (-1)"
= ^...-c,,.

1. sgn(crr) = sgn(cr)-sgn(T), , .
. u = sls2...sr = ..}
sf, tj. = j^-.Vilz'/ ~~ ~
. sgn(crr) =
= (-1/+/ = (-1))' = sgn(a)-sgn(T).
2. sgn(a~l) = sgn(<r), "1 .
. a = sls2...sn "1 = sr..s2Si,
"1 = ^...^^..^^) = (Si(s2(...(srsr)...)s2)si) = en(SiS,) = , st . sgn(acf') = sgn(cj)-sgn(cr"1). , '1 = sgn(e) = 1.
sgn(a)-sgn(cj~1) = 1 , , sgn(cfL) = sgn(a).

7.6.4. Sm
.
. , \\ = \/2,
\Sm\ = ml.
.
. : Sm - Sm, &5 () =.
, cp(a) = at .

212

7.

1. , V^ * 2& cp(aj) (2), = 2-. , , ^) = 2(), = , = 2,


{ .
2. b
, () = (6) =
= *>() = .
1, 2 , .
7, 6,2, Sm.
7.6,5 . G Sm.
. G La : G -> G,

G={gi, &>>= gm} : 0(&) = agf. aG= G


, La 1
(). La Z," -L , ,

Le. G : (LaLb)(g) =
= Lb(La(g)} = b(ag) = (ab)g = Lab(g), .. LaLb = Lab. ,
= {Lgi ,Lg2,..., Lgm } GB , .. ,5^. : G -> Sm ,
Va e Gy(a) = La , () = Lab = LaLb = ()()
.

7.7.

. , S= (1, 2,..., }, G
Sm : : G - Sm. : V^, g2 G

2 ...
" m

1
, g, =

( \

'"

m
a

1 2 m )

7.7.

213

. , * , ,
S.
. S = {1, 2, 3, 4, 5}
. 7.1. G .
. ^ . G, S, : G = {e, a, b, ab),

11 9 \ 4 S ;
={\ ? \\ 11 = (45> -

7.1

2 3 5 4
;

ab
ab

' = (l 3 2 4 \}"^~~

ab

<* =(}1 \3 \
2 5\ ~)~= (23)(45) -

ab

ab

. . 7.1
. . 7.1 , G
G={e, }*{, ].

. s l5 s2 e S g- sl ~ s2, 3g e G, ,
S, Si s2, .. g =

S{
S

'"

^1 2 2 mj

gsl = s2.
7.7.1. g- S .
. .
1. Vsj e S si ~ s2.
, es^ = s^, e e G .
2,

V5j, S2 G 5j ~ S2 > ^2

^1-

Sj ~ ^2, 3g s G gSi = s2ns2 = g~ls{, , s2 ~ s^

j.

VtSi j S^y S^ tJ

iS1]^

^ A iSS "^ - ^ S\

*^>

214

7.

, 3t, g e G ts^ = s2 gs2 = s$, (tg)sl = g(tsi) =


= gs2 = s3. , s{ ~ s3.

7. 7.2. G={gi,g2,..., g^} , S, (. 7.2):


, Vsl,s2eSa # e (?

. 7.2

NG .
1! eSa,
Sa Sa =

. Z(jj) = {g e G \ gs{ = sb s^ e S} sl e S. jj .
. . 7.1.
'= {1, 2, 3, 4, 5} . 7.3. 1
G= {e, a, b, ab},
'12345"
2 3 4 5/
~l 2 3 5 4
! 2 3 45"i aft
=(12345
32 45
" 32 5 4
.
Sl= Ml), (1), 6(1), eft(l)} = {1, 1, 1, 1} = {!},
S2= (e(2), a(2), b(2), ab(2)} = {2, 2, 3, 3} = {2, 3},
S3= M4), a(4), 6(4), ab(4)} = {4, 5, 4, 5} = {4, 5}.
S = Sl uS2 ^ .
{1, 2, 3, 4, 5} .
Z(l) = (, , , ab}, 2) = ) = {, }, 4) = 5) = {, 6}.
7. 7.3. Z(s^) G G.
. .
1. . V&, g2 e Z(^t) g^ = st, g^ = sl} fag^ =
= gi(SiSi) = fe^i = *!> , ^2 e Z^j).
2. e & Z^j), ejj = jj.
3. . g e Z(j1), ^! = sl,
j j =g ^i, , g~l e Z^).

7.7.

7.7.4. Vsj, s2 e Sa \Z(si)\ = \Z(s2)\ n3t&G Z(sl) =


l

= tZ(s2)f , Z(sl), Z(s2)


.
. sl, s2 e Sa, , 3teG
tsl = s2. Vg e Z(s2) (tg)s{ = g(tsi) = gs2 = s2 = ts^ (te)^ = ts{. l
l
1
(# Vi = r (tg)si = t~ (tsi) = (ff'Vi = si, .. tgr e . 5
, Vg e Z(s2) tgt e Z(jj). , Vg, *2 6 2)
1
l
(git' * tg2t~\ , |Z(52)| = \tZ(s2)r \ < \Z(Sl)\ \Z(s2)\ < \Z(si)\.
:
\Z(s2)\ ^ |^1)|, , \Z(si)\ = \Z(s2)\. , 3/ &G
l
\/g e Z(s2) tgt~ e Z(si) |Z(j t )l = 1^)1 = \tZ(s2)t~\

"
7.7.5. \ Sa\=

' '

, ^ e ^a-

l^(*i)l
. G = {gv, g2,..., gk]. 7.7.2
, Sa= {giSi, g^b--, g^}, Sa .
gj ,gi2 e G gj ~ gi2, jj , .. gt s{ =gl j j .
. G ,
Sa= {gis{, g2Si,...,
&s,b .. |, 0 |.
g^s^g^Si ( f t j - f t j )
r 1

fe 1 ^ 2 1 )*i=?r 2 1 fe 1 ^i)

: 1

=^, 2 fe^i) = fe2^ 2 )5i =*!. , ^,/ eZ(5j)


^(i eZ^j^j. , g^ eZCSj)^,
^^1 eZ^^^nfe^,-1^! =*!- ^,^! =g,2sl wuig^-g^.
, gj ~ gt 2 , gt , gj 2
Z(jj)
(gj e Z(sj )gt 2 ), , i1,,; (7 Z^j). 7.3. 1 , \ Sa\ = -^ G : Z(sl )| .

216

7. .

7.7.1 . Sa ,
S = Sl <uS2^j...uSNc 1
G, N G = - /JvC?)!, we\j/(g) = {.ye.S'l.g^S'}.
.
, V# G Vs S
s
s
{(s> ) \S = s}. :
Nq

]T|Z(.y)| = ]T ]|Z(,y)|. Vsl,s2eSa


seS

i^seSf

^\Z(S)\=\Sa\.\Z(sa)\^-^\Z(Sa)\=\G\,
S

seSa
S(l

\^( a)\

eSa. , |Z(j)|=
s^S

^\Z(s)\ =
i=lstS,

\G\=NG-\G\.
'=1

, ^ -|G|= ^1 vfe)l.
. . 7.3. S = {1,
2, 3, 4, 5} . 51 G={e, a, b, ab}, =[|
2 2), fl=[i
< ll./
V X " J J
\L ** J
2 3 45")
3 2 5 4/
, G 5 : S = SluS2uS3,

Sj ={!}, ^2 ={2,3}, S3 ={4,5}. , j


7.7.1 : NG =- |(^)| .
/(*)=, | = *} = {!, 2, 3, 4, 5},
{j e J|os = j} = {l, 2,3},

7.8.

___

217

,
ArG=-l(|vl/(e)HM,(a)H4/(6)|+|vl/(flft)|) = 1(5+3+3+1) =3.
. ,
,
.
.

7.8.
G S= {1, 2,..., }
: G -> Sm Sm. g e G

ki 1;
k2 2;
km .
(kb k2,..., km)
g & G, 1- fcj + 2 k2 + ... + km - .
. Z(G, Xl, x2,..., xm) G,
S, Xi, 2,..., ,

(ki, k2,..., km) g &G.


. . 7.3. S = {1,
2, 3, 4, 5} . G=(c, , , ], ,=(} 2 3 4 5 ^ e = Q 2 3 4 5 ^
2354
(\ 2 3 4 5"\
12 3 4 5 , =
| t ~ 5 4"

l32 45
G, G :

218

7. .

= (1)(2)(3)(4)(5), (k{k2...km) = (5, , , , );


= (1)(2)(3)(45), (k^.-.kj = (3, 1, , , );
= (1)(23)(4)(5), (k,k2...km) = (3, 1, , , );
= (1)(23)(45), (^...**) = (1, 2, , , ).
~'l f v

Y V 0 V Y 0 -1- v 3 Y 1 V 0 V 0 V - l - V 3 V 1 V 0 V 0 r 0 J.

+
2\

7.9.
.
D= {db d2,..., dm} .
G= (Sb 821 ftj--} , D.
R = { 2, 3,...}
().
S= (f\f: D ->/?} ; / D.
Q = {coj, a>2, >>"-} .
: R > Q , () Q
reR.
) = 2]<() <=R
, <=R Q,
{ } J?
().

, .
D= {c?i, d2, ?3} (. 7.4).
, . /? = {, } .
. 7.4

7.9.

219
2

D G= {e, , },
, =\ \ \ \\ ^z \.)

120, = ( | ? |) 240.
1

Q = {, , ~ , " } .
S = \f\f'- D -> R} .
3
R- = {> , 2 . , (. 7.4).
,
. : f \ , f i , f i -

, ^ /3 .
R = {, } : () - () =.
. , () =
() = , , , .
. feS

W(fl ) = ()()() = = ,

. G, D, (,
, ) S.
1
/ V g e G gf=f(g(d))

220

7.

G
/ 2 S.
2
/ ( ( ) ) = / ( ^ ) = /) = ,

, / /3 , 2
, a f2 =/.
. / ~f2, 3g &G\/d eD f\(gd) =f2(d).
/i /2
s

,
/ . (. 7.5):
V/

. 7.5

i ^ V/2 ep VgeGgft *f2,Sa ^5 p , NG -

.
d e D. ,
NG. NG

7.7.1

NG = -~^\\\i(g)\,

{/e S\gf=fwmf(gd) =$ Vrf e D}.


. 7.4 NG. \() = {/e S\ ef=f] / S, |vj/(e)| =
= 23 = 8. \() = { f e S \ af=f} /, 120. ,
, . , |vj/(a)| = 2.
, |( 2 )| = 2. ,

7.9.1. /! ~f2, Wlf^ = W(fl), .. .


. D = { d2, d3,...} D - (gdb gd2, gd^,...} -

Vg e G, G D g =

,2

,3 '"

7.9.

__

221

. W(f{} = J7o)(/1(uf)) = J^oX/j (#</)).


deD

dsD

fi ~/2, 3g e G VdeD a>(fi(grf)) = (/2(^).


.
5, S - Sl
<uS2 . . .vSNc , W(Sj ) = W(f), / e St . , St
/ .
1
2
m
7. 9. 1 . ] = Z(G,R(<s> ),R(& ),... ,R(a )),
S = Sl u S2 v. . -^>SN(! 2

e Q, Z(G,x ' ,2 ,...,^ ) G,


D={d^, d2>..., dm}. ,

. D :
2l +D22+...+D2k2+...+Dml +Dm2+...+Dmkm,
| Dy | = /, \D | = m, 1 k{ + 2 k2 + ... + km = m.
. , / ^ D / , / Dy : yd e Dv f(d) = e R.
/, ,
(12 . . . r2lr22 . . .2^. . .rmlrm2 . . .rmkm ),
r

'J&R~^~
~^
:

Sy - R, i = l,m, j = l,kt. Sy e Sy ) = [4)(riJ)]'nBQCs = (sllsl2...slkiS2ls22...s2k2...smlsm2...smkm ) 6 S

7 . .

<o(s)
o(s) = W(f), /s .
. , , , /
'

W(Sy) = [5 )]*', W(Stti ) = W(SiJ2).

W(Sjj)= ^ d(s) = ^][()]' =R((a'). ,


s eS;i

rsR

g eC g = (P1)(p2)...((3,i XP ;I )((3,2)...

^~

~*7~

..( ... 7 )

~~%T

, (k^, k2,..., km) ^ 1 ki + 2 k2 + ... + km = .



g = (Dn)(Dl2)...(Dlki )(D2l)(D22)...(D2k2 )...(Dm,)(Dm2)...(Dmkm \
^

*2

km

Dy /', |iy = /.
D Dy Ag.
d e Dy g . , Vdb d2 e Dy 3k ^d{ = d2.
. g = (12345)(678), g2 = (13524)(687).
. f&S g &G, \/d e D f(gd) =f(d).
7.9.2. /eS
g e G , /e Ag
?.
. (=>) db d2 e Dy
k
k
. , 3kg d1 = d2. f(d2) =f(g dl) =
d
~) =/(/~) = =/() =f( i) >

7.10.

223

/: \/d sD f(gd) =f(d). , Vrf l f d2 e Dtj /(4) =/(rf2), .. /e Ag.


(<=) d eDy , gd e Dy .
/e ? Vtfj, d2 e Dy f(d{) =f(d2), , nf(gd) =f(d),
/ # e G.
/ Ag,
W(f) = a^,ra ' m '
,> ~ ,
/eAg

fflsQ

, eQ.
, ^ e G, eQ : ^(g) = (f\ \fd &Df(gd) =f(d) /\W(J) = }.
7.9.2 ^ - 1^(^)1.
to eQ,
S -Sl u ^2 u... UA?^ G. , = ^|/(^)| =
I^UeG

= - ^? - \G\g*G

Q, , ^ -> = -

2^ ? 0 ) -= ^^(/) , &g.

W(f)=[R(^)]ki[R((a2)]^ ..{R(<*m)]km ,

7.10.

, -

.

224

__

7. .

7.10.1. ,

G S= G : Vg G \/s S g(s) = gs. | g | = d,
#5, j?s, g3s, ...,/s = s . G
g .
n/d, n = \G\ .
f,

(7.10.1)

y(d) g G | g | = d. d .

7.10.2.
S= {, 1,..., -1}
- (. 7.6) . G
.
G () S
2/. , G = {" = , ,
2,..., "~1}, .
{0, 1,...,
-!} {" = , , 2,..., "~1},
. , 2/ {" = , , 2,...,
"'1} n- , , -> , - 2,..., "'1 -> ".
, , G
. (7.10.1)

d/n

d/n

'

(7-10-2)

y(d) = (d) . ,
d ( j ( d ) ) , G \\ = d. ,

7.10.

225

\ak | = \ \ = d, G. y(d).
NG
(. 7.6) -. ./? = {,<>}.
7.9. 1 .
) =1 >() =1

d/n

( = 3)


NG =^^d)2n'd = 1 (1)2 3 +(2)23 +(3)22 +
= i(l-2 6 +1.2 3 +2-2 2 +2.2 1 )=14.

7.10.3.

S= {1, 2,..., } ,
Sn ,
\Sn\ = \. s SH (&!, k2,..., kn), Iki + 2k2 + ... + nkn = . . , ,
. ,
(3,2) ()()()( -- )( ).
S .
! (klt k2,..., kn), , ,
. kr , . kr
, k). ,
.
82697

226

7.

(ki, k2,..., &). fil


- '- - . 1
1!-l* 2!-2*2.../t/I!-*"
: Z(G, 2,..., ) =
_

v
NG
/? = {, } S= (1,2, 3} (. 7.7). .
={1, 2, 3} S3.
(klt k2, k3)
3 = 1&! + 2k2 + &- : (3,0,0), (1,1,0) (0,0,1).

2,

3?

Z(G, Xi, 2, 3) =
V

. 7.7

3!(,,U

*'*2'

1!1!2;

1M

() =1 (() =1, *) = * () + * () =2. ,

'

=====

I .
Z= {..., -3, -2, -1, , 1, 2, 3,...}.
a,b e Z + , -
. -

( ) , .
, , = bq,

q , : \. a = bq + , 0 <r<b .

8.1.
. , ,,...,
, . () (, ,..., ). (, ,..., ) = 1, , ,...,
. , (10, 15) = 5, (8, 21) = 1.

1. = bq, (, ) = .
2. a = bq + r, ,
, , (, ) = (, ).
3.
. .
> . :
a = bql + r2,
0 < /2 < ,
b = r2q2 + r3,
< / < /2,

228

8.
/2 = + 4>

0<4</-3,

(8.1.1)

4.

5.

6.
7.
8.

*- = Vi?-i + .,
< , < -\,
-\ = ,
, +1 = 0. , , 2, 3,...
b .
(8.1.1) ,
(, ) = (, ) = (2, ,) =... = (/_!, ) = /.

.
(8.1.1) , ti t2, t\a + t2b = rn. ,
(, ) = 1, t{a + t2b = 1.
. (525, 231).
525 = 2 3 1 - 2 + 63,
231 = 6 3 - 3 + 4 2 ,
63 = 4 2 - 1 + 21,
42 = 21 2.
21, , = (525, 231) = 21.
, (am, bm) =
= (a, b)m.
(, ) = 1, (, ) = (, ).
(, ) = 1 , .

8.2.
, , . ().
,
, .. ^| .

8.3.
1. 1 , 1. 1 .

8.3.

229

, 1, , 1 ; , . , 1, 1
, .
2. , , . ,
.
3. ( ) -Ja. ,
q , a = qbnb>q(q ), > q q <Ja.
4. . , plt 2,---,
, .
/?]^---/^ + 1, ,
, pi,p2,-,/>*
5. .
.

1, 2, 3,-4, 5,6, 7,8,9,-, 11, . . . , N.
, 1, 2. 1 , , .
( ) , 2, .
, 2 3
. , 2, ..
, /? (4 <), , 2, .
, N, , ,
-/
8.1
2N+ 1 ; ,
, 3, 5, 7,11
.. X
. X k =\, 2k + 1 ; , Xk = ,
2k + 1 .

230

8.
8.1.

-=(1, 1,..., 1);


for k= 3 to V27V + 1 by 2 do
(X(k-\)/2 k)
{ k]
tfX(k-\)/2 = ! then for i = k2 to 2N+ 1 by 2k do X^.^ = 0;
{ }
for k=l to N do ifXk = 1 then 2k + 1.
Pascal 8.2.
8.3 .
8.2. Pascal'
Program PgmPrimary; { }
uses CRT;
Const
N=45; { 3,5,...,2*N+1}

Vector=array[I..N] of Boolean;
Var
f :Text;
{ }
X :Vector; { }
Procedure Primary; { )
Var

i,k,M,nm :Integer;
begin
nm:=2*N+l;
for k:=l to N do X[k]:=TRUE;
k:=3;

M:=trunc(sqrt(nm));
while k<=M do begin
if X[(k-l) div 2] then begin
i:=k*k; { k}
while i<=nm do begin
X[(i-l) div 2]:=FALSE;
i:=i+2*k;
end;
end;

k:=k+2; { k}
end;

8.3.

231

{ X[k]}
i:=0;
for k:=l to N do
if X[k] then begin
Write (f ,2*k+l, ' ');
end;
WriteLn(f ) ;
WriteLn (f, ' '+
' [3, ' , 2*N+1, ' ] ',i);
end;
begin
Assign (f, ' Primary. out' } ; { }
Rewrite (f ) ;
Primary;
Close (f) ;
end.

8..
iinclude <stdio.h>
#include <math.h>
ttdefine N 45
char X[N+1];
//
// 3, 5, . . . , 2*N+1 }
int main (void) {
FILE *f;
int i, k,M, run;
f =f open ("primary . out", "wt") ; //
//
nm=2*N+l;
M=sqrt (nm) ;
for( k=l; k<=N; k++ ) X[k]=l;
for( k=3; k<=M; k+=2 )
if ( X[(k-l)/2] )
for( i=k*k; i<=nm; i+=2*k ) X [ (i-1) /2] =0;
//
i=0;
for( k=l; k<=N; k++ )
iff X[k]){ i++; fprintf (f,"%d ",2*k+l); }
fprintf (f , "
[3,%d] %d", 2*N+1, i) ;
fclose(f ) ;
return 0;

232

8.

8.2 8.3 2N+ 1 [3, 2/V+ 1]


. 2N+ 1
N. 3 .
8.2 8.3 Primary.out :
3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89.
[3,91] 23.

[3, 27Y+ 1], .


.

8.4. ,
, . ,
, - = t t, ..
b . = b (mod ).
, 77 = 5(mod 8), 102 = 0(mod 3).
1.
2.
3.
4.

5.
6.
7.

8.
9.


= a (mod ) .
a s b (mod ) => b = a (mod m) .
= b (mod ), b = c (mod ) => = (mod ) .
= b (mod /) => (, ) = (, ).
= b (mod /), = d (mod m)=*a + csb + d (mod m).
a = b (mod m), c = d (mod m) => ac = bd (mod m).
a = a\d, b = b^d, (d, m) = 1, a = b (mod m) => a{ = bi (mod m).
a = b (mod /), // ({ ) => a = b (mod m{).
a = b (mod m), d\a, d\b, d\m => a = b\ (mod m{).

8.6.

233

8.5.
13 ,
.
Zpa36nBaeTCH (. 8.1), .
, s eZea {&,}, .. , s e {&,}
, = s (mod )
.
, .. , s {&,} ,
(, ) = (s, ) (. .8.4). ,
, .. , , .
z

(0)

{1}

{2}

{3}

{4}

(5}

{-2}

{-1}

. 8.1.

. {0}, {!},..., { - 1}
(...). .
Z ( ) , mZ , . Z/mZ ( ).

8.6.
. . {0}, {!},..., [ - 1} ,
().
, ,
..., . : , 1,
2,..., -1.

234

8.

8.6.1. .
. () .
1. . a, b . ,
. = 1 (mod ) b = 1 (mod ),
ab = 1 (mod ).
2. .
3. 1.
4. .
. = . , , . =
,
. , ^ * 2 ,
abi - 2 = 0 (mod ). ( - 2) = 0 (mod ).
(, ) = 1 , \ - 2= 0 (mod )
bl = 2 (mod ),
.
, ^ , , , b = 1 (mod ). b
, ( ).
, , .
.

8.7.

. <p(w)
1, 2,..., /-1,
, 1
(1) = 1.
. (1) = 1, (2) = 1, (3) = 2, (4) = 2, (5) = 4, (6) = 2.
. , ()
|Afn(m)| = ((/).

8.7.

235


1. (mlt 2) = 1, ^ 2) = y(ml)y(m2).
1. (/1/2) |(/!/2)| = {2, (({2) (CM.
7.3.4). (^-^ = 1,
(. . 7.4) (7!/2) (/!/2) = C(/Wj) x C(m2) , , ^^^ (p(/Wi)(p(/H2) 2. ,
1. , (^^ 1
, 2 + ^ = 1 ( .
.8.1). {1, 2,...,
^ {1, 2,..., 2], a/n2 + bm^ = I(modm 1 /n 2 ).
{1, 2,..., /ni/2}, 2 + cbm\ = c(mod ^2) , cb {1, 2,..., / W j }
b {1, 2,..., /2}. , {1, 2,...,
mj/w 2 } /2 + \ = (mod /njm 2 ),
{1, 2,..., /nj} {1, 2,..., /2}.
, (, ) ^2 (1, 2,..., W!/w 2 }-
2 + \ {1,2,..., /wj
{1, 2,..., 2}.
2. ( 6 ^(2) , .. (, /Wj) = 1 (6, /2) = 1
(/!, 2) = 1. , (2 + bmlt /1/2) = 1.
(2 + bmi, ^) = 1 (2 + {) = 1 (2 +
+ bmlt 2) = 1. (2 + bm\, W j ) = (2, ^) =
= (a, /HI) = 1 (2 + {, /2) = (bmh 2) = (, 2) = 1.
(, ), 2 +
^2, y(mi) (/2). ,
{2 2 + bml .
3. 2 + bml,
M^ni]) < (2), (2 + \, ^^ 1, .. ^^
4. 1), 2), 3) , (/!/2) =

236

8.

2. (") = -

= 1 ,
I )

> 0.
1
. k , k={\, 2,..., ~ }

1, 2,..., ,

. ( ) = - ~ .
3. 1
2
=^ ^ ...^ , p i ,

_*_

~1'=

4. 2^(*/) > ^ ~ .
d\n
[

1. =^ ^ ...p^
.
(. . 3.4) :

= l + ( - 1) + ( -) + ... + ( - "- ) =.

(<=
Z
(^)=
'=d\n
i=ld\p4
i'=l

2. ()
|()| = . d C(d) () |()| = d. C(d) Sd = (. () | | | = d }. 7.3.4 , C(d)
( = \Sd\. Sd r\ Sd- = 0 rf 7t d', [J^j =()
d\n
(/\

8.7. _

237
()

8. 7.1 .
= 1 (mod ), > 0 (, ) = 1.
.
, \\ = <(). , (, ) = 1 = (mod ), ^.
,
(, ) = 1. 7.3.1 , . k
, .. = 1 (mod ). (/) = k d, d ()
. /* = /^ = 1 (mod ). = (mod )
(|)
(m)
<)
, = /* (mod ), , a I (mod /).

$. 7.2 . = (mod ), /) ;
.

. = 0 (mod ), = 0 (mod p).


= (mod ), re {1, 2,...,- 1} , , (,) = 1.
, *^ = 1 (mod ), q>(p) =p-l.
^1 = 1 (mod ^) = 1 (mod /7).
8. 7.3 . (-1)! + 1 = 0 (mod ),
.
. = {1, 2,...,- 1} . .
:{1, 2,..., - 1}
{1, 2, ..., - 1} , = 1 (mod/?).
, = 1 (mod;?) : ; = 1 = - 1. 2 - I = (- 1)( + I) =
= 0 (modp) - 1 = 0 (mod/)) + 1 = 0 (mod/)). = 1 = - 1. ,
=\ =-1.
: {2, 3, ...,/> - 2}
{2, 3,..., - 2} ,
= 1 (mod/)) *. 2 3 ... ( - 1) = 1 (mod/)). 1 ( - 1), 1 2 ... (-\) =
= (-\)\ = -\ (mod/)) (- 1)! + 1 = 0 (mod/)).
, /) hb H2,..., hn . p
p
, (A! +H2+...+hn =h*+h 2 +...+h n (mod/)).

238

8.

. (8.7.2), hf =A,(mod/>),
/ = \,. (. .8.4) hf =hj(modp) :
h

{ +h2+...+h% = hi + h2 +...+ hn (mod/0- ,

(Aj + 2 + ... + = AJ + 2 + ... + hn (mod p),


.

8.8. .

. ()
1, = 1,
, n=p^pl*...plk ,- >1,
1)*, ^
= " ' % . - .^k ,
pt , , pt .

. (1) = 1, (2) = -1, (3) = -1, (4) = 0, (5) = -1, (6) = 1,


-1, (8) = 0, (9) = 0, () = 1, () = -1, (12)=0,
(14) = 1, (15) = 1, (16)=0, (17) = -1, (18) = 0
(20) = 0, (21) = 1 , (22) = 1, (23) = -1.
8.8.1.

( = {?' >1>
^
[1, = 1,

d .
. = 1, ^(/)=(1)=1.
d\i
2
=^^ />* \ . >(</) =

(</) = jrcrk (-IY =(1-1)* =0. d,


r=0
r

( ^ 0, ^^.^^ ]i(p,1pil...p,r)=(-l) .
pt pi2...pir, 1,2,...,
pk, Crk .

8.8.

239

8.8.1. :
/() = ^g(d\ g(n) = >(</)/(),
/(), g(n) , .
. /(4)
,

<

"

= d 5 , dvi
5
, ..

5>( I>(5) = 2 2>0)1 (</)


(</)=
= 1''
' </\(f)
I ' -
\
s\ . \
*
\
8.8.1.

5\

. () (). ^n(d) = 4 (. .8.7).


d/n

:
, ,
>=
d\n

d\n

d\n

, = 6 q>(6) = 2, </ {1, 2, 3, 6},


|(1) = 1, (2) = -1, (3) = -1, (6) = 1 , ,
^^= ^^ \-\+=^ + ^ + \d\n

=^1 ?2 ---^ ~ .
k ( \\
()=-]~]] 1 3 (.
/=

Pi J

.8.7), . ] 1 - = .
i=14

<//

1=14

d/n


1. (..
) :
k

C -C
>
- 4-1 +4-*"
4-1 -

2. :
) * =2";
=

) -* ^"-^

) (-1)* =0.
k=0

LL,

3.

'&

^2, i^

Z Z Z Z1 =
-2=1

'2 =1 4=1 '0=1

4. , ""' = - , > 1.
'
2
.
(2)! ()! ( )! (2)!
5. , :
2" ' 2"3"' " '!( + 1)!
.
6. (a + b)" =

"

7. = {alt a2,..., an}.


2
8. , ^Q * =c2*+1 =2n~l.
k

241

=+ ZXC* )

9. , ^

).

/=0

2 ( -

*=0

10.

11. ^* = 2 ^'" 1 .

12. ](-1) -* =-L .


=0

,
13. 2] * -1i +
-2

14. ^

^ -

\- .
=k", -

k :
= ! + 2 +... + nk, > 0 .
15. 5 ,
. ?
16. 11"
(, , ; 11 )?
17.
2 2 ?
18.
In 2 , ?
19.
{0,1}?
20. ,
5 ? ,
.
21. 6 .
, 3
?
22. 7 , 9 .
?

242

23. ,

?
24. . , , . ?
25. 5 , 7 3 .
15 .
?
26. . +
. ?
27. = (^ 2,..., ),

, = {0, 1}, / = 1, 2,..., , ^, =.


i=i
28. .
,
, ?
29. : 2
, 2 , 2 , ?
30. k , ,
. . ,
?
31.
, ?
, , , .
32. 12 15 .
4 ?
33. ( > 2)
. , . ?
34. 10 .
6 , ,
?

243

35.
,
?
36. . ?
37. ?
38. 2
, ,
,
. .
39. ,
1
2"~ .
40. 3 , 3
3 ,
?
41. 52 .
10 : ) ; ) ;
) ; ) ?
42. 6 , 52 , , ?
43. . ,
: , ?
44. 17 .
. , , . ,
; .
45. .
46.
.
47. :
) ;
) k ;
) & alf a2,.., ak ?

244

48. \ , 2 3 ?
49. 3 6 , 1 , 1 , 1 , 1 , 1
1 ?
50. , ,
. ?
51. , , :
) ;
) ?
52. 5 36?
53. ( 5 36) : ) 3 ; )
3 ?
54. 30 1,2 5 ( , ..2.2.2)1
55. , , ,
3 , 2, 3,
1 ?
56. ^^] (xl +2 + 3)10 .
57. q =*1 ^ ...%", /?, , , ,- ? ?
58. , \
/" = + + +
59. k 1 , k .
< ?
60. , ?
61.
. :
?

245

62. , , , , .
63. 20 .
,
, ?
64. 40 .
10 ,
. ,
60.
65. 25 . ,
30 5 ,
.
66. . , ,
, 156. ,
8 9 ?
67. 41 . : 5,4,3. , , ,
.
68. . , 17 . , 17
( , ..2.2.2)1
69. : ,
1, , ?
70. 1, 2,..., -
, . , 2-2[182"1+1 +L
71. k (,
, ), : )
; )
?
72. 271845936?
73. 50121200?
74. ^.-.,,
dld2.-.dn. ( - 1 - d^)(n - 2 - d2)...( - dn)?

246

75. Nnm . , , 2 1/2 : N,


2; , 1/2;
,
1. ,
2""".
16. 3
,
?
77. nk
k , , , . ?
78. 30 3 10 ? 10 3
?
79. 36 , ?
80. 10 5 2 (
)?
81. 9 4
2 1 1 ( )?
82. 9 3
3 (
)?
83.
( , , ,
). ?
84. 9 7
2 ? , .
85. 8 . , , , ?

247

86. , k
, . . = xl +
+ 2 + ... + xk, Xj > 0, / = 1,2,..., k, */, 1
k 2"" .
87.
k , ^
, 2 .., k-
nk , = ^ + 2 +... + nk?
88. 0 10",
?
89. - ,
?
90. ,
10", ?
91. k
, ?
92. ,
. ,
k. ?
93. ,
,
? , (, ) .
94. , 1, 2, 3, 4,
5, 6. (, , )?
95. : .
, ?
96. & .
,
? :
.
97. k
, . :
.

248

98. , 2,...,
#!, k2,..., km.
, ,
kj ( )? : .
99. . alt a2,...,
kl; k2,..., km.
,
, &,, ? : .
100. , . :
.
101. ,
+ , ,

, , ( + ) -*( + -1) +
+%( + -2)-...+(-1)"%(+-). :
.
102. . , > 2. ,
. , ](-1)*^2*(2-:)!. :*=
.
103. , 1000 3, 5 7.
104. , 1000 6, 10 15.
105. , = 30, , 6, 10, 15, 22.
106. ,
60% , 50% , 50% , 30% , 20% , 40% , 10% , .
) ; )
; ) ?
107. ,
. , , -

249

. ,
, . : ) ; ) ; ) ?
108. + 1 ( , 2
). , 2 " .
109. ,
: AC, + 2 +... + = , ,- < Xj <bhi=l,n, ah xh bj .
110.
{ + 2 + *3 = 40, : > 3, 2 > , 3 > 2.
111. , 10 ,
5 4 . ,
?
112. , . ,
?
113. 2 1; a l s a2, },--, , .
In , ?
114.
4 .
,
?
115. . ?
In ?
116. In
.
117.
, ,
. ?
118. ,
, (. , 6, ) . ) .

250

119.
+2
{2( - 5) + 7" }.
120.
3
1 + 2 + ... + .
121. :

8
10
!) "+2 - 4+1 + = . " = . 1 = ;
2) +3 - +2 + +1 - = 0, 0 = 1, M! = 3, 2 = 8;
3) +29 = 0, 0 = 1, H! = O;
4) +4 4 = 0, 0 = 1, ! = 1, 2 = 1, 3 = 1;
5
) + + +2 - "+1 - = 0, 0 = 1, M! = 2, 2 = 3;
6) +2 - 4+1 + 4 = 0, 0 = 1, M! = 2.
122. :
M =I
!) "-1 = + > O ;
2) +2 = -2n+i + 8 + 27 5, 0 = 0, , = - 9;
3) +2 - +1 + 2 = , 0 = 1, M! = 1;
4) +2 - 4+1 + 4 = 2", 0 = 1, M! = 2;
5) +2 = +1 - - + 2~", 0 = 1^! = 3/2;
6) +2 - +1 + 2 = (-!)", 0 = 1, Mj = 2.
123. {}
+2 = +1 + , 0 = 1, MJ = 1. ; ,
+1 ,
= k.
124. :
!) +2 = "+1 - 4 >
2) +2 - 4+1 + = 0;
3) +2 ~ +1 - " = 0.
125. :
_

'
_ -1

(\

126. + 2 = , , , s Z+
; , .
127. + 2 + 4z = , , , Z+,
, , z .

251

128.
fa + p a(3
1 +
1 +

+
, ;
.
129. ^(1/2*),
k, 2, 3 5.
130. ) ) . ) . ), ) )
.

131. 5 5 x 5 ,
. d) .
132. 5 5 x 5 ,
.
d) .
133. 2 ), ) ). 1.
.

~-\^
)
*"--

254

163. - , > 1.
164. , 6
, .
165. , 6
3.
166. - {1,2,...,
}, {1, 2, 3}, {4, 5, 6},
...,{3 - 2, - 1, }; ,
.
( ), 3" .
167. , ;
(( - k)(n - k+ l))/2.
168. , , . : , ; ,
.
169. . ,
. :
.
170. ) ) ,
( 6.7)
( 6.9). .
xl

20

171. $
(. . ).

255

41
)

172. * =[! 1 i,j= l,n k-


. , \^
k , . :
k.
173. .
, , , . , .

174. n- , d?
175. , .
176. ( > 2)
2, . ,
2 - 1.
177. , , , , .
178. , > 2
.
179.
. , k , ,
k < d(xk) + 1, ( =s k, d(xk) xk.
180. ,
- d(x) + d(y) > ,
.

256

181. (. .6.14.3),
- (F! u V2, U, ) , V{ = {slt
s2, s3, ,y4, s5, s6} V2 = {I, 2, 3, 4, 5, 6}, :
- {I, 2, 3}, s2 - {1, 2}, s3 - {I, 2}, s, - {I, 2, 3, 4}, s5 - {I, 2, 4, 5},
Sl
s6 {I, 2, 3, 5, 6} = {(sb 1), (s2, 2),
(s4, 3), (s5, 4), (s6, 5)}.
182. (. .6.14.3),
= (F! u V2, U, ) , V{ = {sb
S
S
1
s2, ,, ^4> 5> 6> -s ?} ^2 = (1) 2, 3,4, 5, 6, 7}; : Sl - {1, 2}, *2 - {2, 5, 6}, J3 - {5}, *4 - {! 2, 5}, *5 - {3, 4, 5, 6},
s6 {4, 5, 7}, s7 {5, 6}, = {(jb 1),
(s2, 2), (53, 5), (s5, 3), (J6, 7), (^7, 6)}.
183. ), ) ) , , (. .6.10).
, .

257

184.
)

2
8
1
8
9
12

6
7
5
7
11
9

4
2
3
1
1
9

7
4
4
2
3
4

1
3
3
0
3
5

10
7
17
2
9

15
1
18
11
14

11
14
16
8
6

2
8
16
3
1

9
6
15
5
10

2
5
3
1
6
7

185.
)

92697

4
13
9
12

6
10
9
10

9
14
16
12

7
14
13
10

9
38
28
58
30

20
71
13
34
3

60
69
80
13
53

15
49
28
37
20

21
60
34
25
21

44
22
28
49
27
70

74
28
39
53
37
27

35
42
54
45
30
21

49
59
47
50
18
32

30
83
35
43
30
31

45
41
24
38
22
9

258

186.
, , , D, , , ,
d, e. :
-

D-d

60

30

100

50

40

S, , U, V, W. ^ S, U, Vw. , W.
Y,
, .., :

20

40

30

60

X
Y

V
W

30

40
30
10

10

30
40

20
10
10

20
40

20
30
10

20

20

40

20

30

30

20

10

30

40

, .
187. , , :

9.00

10.00

11.00

11

8.00

10.00

12.00

12

9.00

11.00

15.00

17.00

13

14.00

16.00

19.00

21.00

14

20.00

22.00

20.00

22.00

15

21.00

23.00

259

, , 1 .
188. , , .
:

8.00

12.00

9.00
10.00
14.00
18.00
20.00
7.00
9.00
13.00
18.00
9.00
15.00

12.00
14.00
18.00
22.00
23.00
11.00
13.00
17.00
22.00
12.00
18.00


? , 1 ,
.


189. , Gl = {n\n & Z}
, Z ; G2 = {2 | Z}
; G3 = {2" \ Z} ; G$ , ,
; G5
; G6 = {1, 1} ; G1

( ); (78 ( ). , .

260

190. Va, b
ab~{ . , .
191. (?!, G2 /: G{ - G2 . , .
192. GI = { R+} G2 = { R}, R+
, R . ,
Gl , G2
. : G{ -> G2 ,
Vx e Gi () = 1() G2. , .
193. G G . : G - G Vg e G(p(g) = r~lgr. , .
194. , G In G, .
195. , rx.snr+s>n, .
196. ,
( 12345}
(2 3 4 5 lj'

197. (3 2 4 7 5 6 i s) (? 6 2 ? 4 5J ,
.
198. S^, 54 .
:
\ ffl 2 3 4W1 2 3 4W1 2 3 4Wl 2 3 4
a a
> -\(l 2 3 42 1 4 4 1 2J'U 3 2 l
fi^y
ff -If1 2 3 4Wl 2 3 4Wl 2 3 4Wl 2 3 4
H
> -\(l 2 3 4>U 3 1 4>U 1 2 4>U 4 1

199. G , \G \ = . ,
(/) .
200. G . ,

G.
201. G \G\=p,p . , G .
202. , .

261

203. G . , g G
k, g = e.
204. , G = {g,
g*,...,/' = } ()
{1,2,...,-1} .
205. G \G\ = ^^2...
/>"*,
rp,,p2,...,pk ; () =

= ( G \ \ x | =}, < . , () .
206. Gb G2, \G{ \ = 56,
| G2 \ = 64. .
207.
S3 ,
\\^ |\
.
208. (), ), ), ), ). .
V

209. ), ),
), ) .
210. , , .
,
() .


211. . , 1 .

262

. .
.
, , (.. , k- , k, k+ 1,..., ),
.
, ,
'- ,
/. 1;
2,...,, , ,
? alt a2,..., . , . ,
= = 9 ({, 2,..., ) = (3, 1, 4, 1, 5, 9, 2, 6, 5),
: 2, 4, 1, 3, 5, 7, 8, 9, 6.
212. . , . .
1 .
,
.
, , , .
, , , , .
.
k, , ( > 2) k , . Ik
.
.
pt (!</?,< /2), ,
. PJ , , pi , .

263

: <, > =.
< , .
> , .
= ,
.
.
.
, 0. .

5 3
2 1 2 3 4
<
1 1 4

1 2 5

4
3
<

1 1 2
2
<

2
>

213. . ,
1 , . .
, :

,
;

,
( ).

.
. : , . .

264

# . . . .

.
:
5 10
##
##
.#..#...#.
.###
##
. .##
##
#.

.
214. .

1
3 8
8 1 0

2 7 4 4
4 5 2 6 5

. ,
, ..
. ,
7 , 8 , 1 , 7 , 2 25.
.
,
. : . .
:
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5

:
30

7 3 8 7 5

265

215. . 2 , , ( < 5).


\A\B\B\A\ \ \A\B\A\B\
. - 1
- 1 .
,
,
. : ()
, .
. : 2 . : | | 2? | . | | | | | 5 | | .51
.
.
.
216. . .
.

11 6 11 3
7 9 6 13 5
1 10 12 7 13
13 11 10 8 10

10
7
13
14 13

: .
( ) ,
. : 1 (
), 2 ( ), 4 (
), 8 ( ). , 11 (11 = 8 + 2+1),
, .
. : , .
,
. . . .

266

:
4 7
11 6
7 9
1 10
13 11

11
6
12
10

6
13
7
8

3
5
13
10

10
7
13
14

6
5
5
13

:
9 6 3 2 8 .

217. . , 1 N.
. . (1 < < N)
, , ,
, .
-,
, .
N, M . .
218. . ( ) ( ),
.
: H[i, j ] , i = l,M, j = \,N
. , . , ( ).

. : , N

267

. : = (iaja), B= (ib,jb) .
H[i,j}, i- \,M,j= \,N.
. , .
219. . ( ), k .
( j>j), (jc2, 2),, (, )
. (
, (; >>,), )
. ,
( yt).
220. . :

-\

, , .
1, 2,..., ( ) , / /- . ,
,
/ /- .
( ). :
.
. :

.
221. .
, 2,..., .
: -

268

1,
, . k , {, 2,..., . , ;?
, . n,kw.
\, 2,..., . .
:
5 2
7 1 15 8 3.

:
.

222. . , 1 < < 1000.


,
, .
, .. /
, ./ /. , . ,
2 ,
, ( ),
( ).
. NO.
. . /- , /'.
.
NO. , , 2 ,
, .
.

269
:
3
1
1
1
2

2
3
4
3

223. . 1 ,
. .
,
, . , , .
.
- , ,
.
.
, 1 < < 1000, . , ..
(/+ 1)- , /- ,
, . .
224. . 9 1926 . . .
.
. , . . , ,
, . :
? ().
, , ?

270

, , . 1 .

.
.

25
20
3121


3 1 .
.
5 1 .

-1

225. . . 2:00 . ,
. , , , ,
.. . 60 /.
. 30 /. ,
( /),
,
2:00 .
.
, .
(1),
.
. : LengthGreenYellowRed(LGYR) , L , ; G, Y, R : , .
:

271

5.5

48,49,50,51,52,53,54,59,60

40

25

10.7

10

75

12.5

12

57

17.93

15

67

30, 32, 33, 36, 37, 38, 41, 42, 43, 4 4 , 45,

0 .

226. . N .
(),
. . ,
.
,
, . . ,
, . N=7 N=31.

7
31

3
2

4
3

227. . = (X, U, ), .
. . .^ = < . ' ,
. X, (, ) / . .
,
Z 6 X.
z 6 X, .

272

, . , ={1, 2,..., ), \<< 1000.


,
.
: , , z, , ,
Z .
: 1} 2,..., \ ^ ... ,
bj=l, i ; bt = 0, i
; xyt , , , ! .
, .
:
7 12 7

0
1
2
3
4

1
2
4
1
3

0
1
2
3
4

0 0 1 0
4 1 3
5
6 3 7
6

5 6
6 7

,
1 2,..., , , = 1, /
; , = 0.
:
0 1 0 0 1 1 1

228. . .
,
: 1 , 0
,
: .
, .
1 0 2.
,
, .. ,
, .
. .

273

.

1) 01210
2)
3)
4)
5)
6)
7)
8)
9)
10)

21120
21001
12110
12101
12101
00011

6
Q

3
2
8

1 10

1
1
1
1
0

1
1
1

1
0
0

0
0
0
1
1

1
1
1
0
1

22222

11001
10010

229. . :
!, 6j, 2! 2,..., , .
. , . .
. :
. , .: a,, bt
. .
:

2
-1 1
1.

:
.
230. .
, , . .
231. . . ,
.

274

232. . Y 7V ,
. . ,
XOY.
.
N. N : (,, ,) ; (/, d,) .
,
.
:

1
3
2
6
8

3
5
7
5
8

12 7

7
5
9
14
13

1
2
4
2

15 4.

:
.
233. .
, , ,
. . . , ,
, .
:
24
1 0 2 0
2 0
0 0 1 0
1 1 2 1 2 1 2 2
2 2 3 2
1 2 2 2
3 2
0 3 1 3
1 3 2 3
2 3
0 1 0 2
0 2
0 0 0 1
1 1 12
3 0 3 1

3 0

4 0

4 2
3 3
0 3

3 3 4 3

5 0

4 3 5 3


4 0 4 1

4 1 4 2

5 0 5 1

5 1 5 2

275

5 2 5 3

:
11

234. . . , ,
90, 180, 270.
. 1, , 0
.
:
4
0
2
1

1 0
3 0

1 4
0 4


2 0
1 0 2 0
3 0 3 1

1 4

:
1 .

235. . : ^, 2,..., .
,
. .
. : .
/.
:
5

6 3 1 4 5 .

:
3 1
4 5 .

236. . 1, 2,..., ( ) . -

276

1.
,

, 1.
. .
.


1 4 3 2 5 6 1
1 2 3 8 5 6 7
1

4
6

1
1

237. . / ( ). .
.
. .
, computer , , 8. , .
, . . . .
.
, , .
. .

3
one
two
three

11

238. . N , : (*![/], yl[i\)


(x2[i], y2[i]). -

277

,
.
, .
: N . :
x l [ i ] , y l [ i ] x2[i], y2[i] ( ). ^ . , .
, .
239. . 1 , 1 < < 5000.
, . , = 8
: {1,4, 5,6, 7}, {2, 3, 8}. : 1 . .
( ),
. , .
:
:
1 2 2 1 1 1 1 2 .

240. . , , NX N. # , , , .

. .
, . N. N , .
.
,
1 ( ).

278

##-##1#
:
18.

241. .
. NX M
. .
.
. , . .
N, . ./V N *. .
.
. , .
:
3
1
1
1

4
1
1
1

7
1 1
2 1
2 3

:
12.

242. 241 ,
.

279

243. ..
1, 2,...,
, (-
).
.
.
244. . . : 1, 2, 3, 4, 5, 6, 7, 8, 9,
, +, - ,
. , = 122,
: 12 + 3 4 - 5 - 6 + 78 + 9.

+, -, . . .
, 1.
245. . , ^,^,...,. ,
, MAjM
[cijjb,]. , , ,
MAtM, a bt ,
. , [,,6,], / = 1, 2,..., . ,
.

3
1
2
3


2
3
5

280
5
1
7
6
2
9


3
12
8
4
10

246. . .
, ,
,
. , .
1 . .

.

5
6
1
2
1
3
2

247. . d^d2...dn ( 2,..., ),


dj , j j
(.. 1.13). 1, 2,..., . .
:
5
5 3 4 2 1
:
4 3 1 1 0 .

1. D % D = Dl D2, n D2 = 0. Z)t
1
, |Dj | = C^Jj . Z>2 , \D2\ = C*_l. ,
2. (l+jc)" =
3. . 7. 2".

8. ( + b)" = ^ "~ .
k=0

9. (1 + ) (\ + )" = (1 + )
10. (! + (! + 1))" = 3".
1113. (1 + )" =
14. .
(1 + 1 + ... + 1)" = k".
15.21. 16. 2+2. 17. 2222. 18. 22 (22 - 2). 19. 2.
20. 5 3 ,431 21. 6. 22.63. 23. 2 , 2 , .
24. . 25.P(5,7,3)=3f5[=C155C170C33. 26.%+. 27. ^.
28. ^ +^ + .

29. (2,2,2,1,1).

.** 31. 2!!2!!/2 = !(-1)!. 32. q4^ 4!.


33. !/2,
;
2 ()
.
34. Cf0(Cf0 -l)(Cf0 -2) =^ . 35. C^C^qj .
36. 6((624222)/3!) =15cJ. 37. 6((624222)/3!) =156.
38. ((2)!/(2!)")/! .

282

____

39. . 7 8. 40. 9!-^7!3!+325!3!3!3!-333!3!3!3!.


1 1) rw 110 - 110 rlri r2rs
U

41. ^4*"48' 52 -*-48> -52 ~*-48 ^ -4 -48' 4 -48


3

42.( 4 )(') +( ( ) 1 3 ) .

43. 3ffl

44. 17.

45. ".

47 ""-1
_/"""-! -2
fm-k-l
/
|
' ^(-/)+-1 ~Si-l ' *"(-*)+-2' "(-, )+-*-! '

"""1

"""1

(\ ~1
<
Si+wi-

"""1

"""1
2

51. 5 , % . 52. |6. 53. ^ , |6 -^ -\^ - ^ .


55. (3, 2,3,1).
l - n l 1-^2

j_

56. C^Cj3.

57. (1 + a i )(l + a 2 )...(l +),

- * -- ... - - . 59. - [/] 1, 2,...,


1- 1-
!-
^. *, , ., -%_[/]. 60. ! - \( -+\)\ ( ).
61. 2 ( 2 ) 2 =5J!L _ ,
. (},)2(-\)=2(-\) , .
.
63. 20 +20 =90. 66. 18. 68. 31. 71. *;^, *;/.
72. 205223000, . . 1.13. 73. 27354186, . . 1.13.
75. : ,
N 2"~.
76.3CJ,2". 77. (foi)!/(OH)"ii!). 78.
79. (/2\)-($).

80. (C20C82C62C42C22)/5! =

81. 9!/((1!)1(2!)41!4!). 82. 9!/((3!)33!). 83. (2,2,2,2,2,2,1, 1,1,1).


84. Cf5Cf0. 85. 48 -^8 +|28 -4318 : , /'- ,
...
89. Cj;j _ 90. ^^^ -1, -1 0.
91. ^+1 . 92. C*+k . 93. .

94. ^. 95. . 96. *( -/.


/=

283

k-r

k-r

07 W IV'"1 Cr+l (b r /V -r""W 1V " CJ-


"' 2i*~ ' r+i^k \1^~1) ~*-'k2-i^~ ' k-r\ ~ ~ > '
i=0
m

*=o

*=o

/1=0

m-r
/UO

/UO

i=0
t

*
m-r

' A=0

102. . , k- , k = 1,2,..., . ) , , ..
. ) = (0) - W(l) +
+ W(2) - ... + (-l)"W(n), W(k) , k .
k . 2 - k , (2 - )! .
k 2k .
k Ck .

, ) = V^(-l) C 2 (2n-k)l
k=0

103. 542. 104. 734. 106. 20%, 60%, 70%. 107. 2, 6, 3.


109110. .1.7.
111.
|5! I'^yV112. 3_2. , - 2
3_2 , , . ^ < k2 < k3,
2 + 1 < & + 2.

.
115. 2", ^ . 116. + 1. 117.
i xj ( - / + 1) (n -j + 1). , . -

284

k 2

118. ) !** +2(;-1)!*- *- +(k-2)\C n~ C m ; ) + 1.


119. _4__--+ _?!_. . (( + 1)/2. 121. 1) 7 + 3";
2

2n+1

2) 2 = [9 " + /10, 2+1 = [9 3 + 3 (-1 /10, > 0;


3) (+9)"; 4) (+4)"; 5) (-!)"( - 1) + 2; 6) 2".
2
2
2
122. 1) +2 -2 +1 +2 ; 2) -2(-4)" + 3 2" + 5";

1\ ,1
. II

-1. 0 \

D . ". -54

X l J.T-V-'

| I"'VJ

+1

n+l

125. an = 2 (2n + 7), bn = 2" (-2 ~ 3).


126.
4

129. .
3
130. a) R(x, ] = (1 + ) + (1 + + )(1 + ).
133. ) 2", ) 2 ""1.
(..3.3). 134. ) 2 " + ( 1 ) 2 , ) |(3"-J -(-l)"'1). (..3.3).

135. 4".

136. 22.]( ) =(2) .

x + +>> +

2"

+~

2 .
(. .3.4). 137. ^, (. ).
183. ) 14; ) 18; ) 9. 184. ) 43; 6)61. 185. ) 37; ) 100; ) 158.

1. ., ., .
. .: , 1979.
2. . . .: , 1962.
3. .. . - .: , 1969.
4. .. . - .: , 1981.
5. .., .. . - .: , 1977.
6. ., . . .:
, 1987.
7. ., . . - .: , 1971.
8. ., . .
.: , 1981.
9. .. . : , . , 1991.
10. . . .
.. - .: , 1978.
11. . . /
. .. .: , 1980.
12. . . .: , 1975.
13. . . - .: , 1978.
14. .. . - .: , 1973.
15. .., .. . .: ,
1992.
16. . . - .: , 1980.
17. ., . . .: , 1989.
18. . . .: , 1966.
19. ., ., . .
. - .: , 1980.
20. . . .: , 1963.
21. .. . .: , 1972.
22. .. . .: , 1977.
23. .., .. . - .: , 1966.
24. . . - .: , 1973.
25. ., . . .: , 1977.
26. . . .: , 1970.
27. . . . - .: , 1978.


125

227-228
177-179
6668
113

(=)
114
84
6875
115
114
89-90
76
( ) 178
8588
111
79
137
80
186

186187

151-155
(=) 112
126-129
151155
113

125
186-188
116
182184
117
() 117123
111
160171
110
131136
111
112
156159
137138
112
145-149
111
139144
113
172176
113
185188
113
216
156-159
237
172176

194
() 56


113
113
() 81
233
113
233
130
234
113
113
113

113
180-184
113

130
112
130
112
197
112
203
185
233234
183
198
, , 196
199
112
199
111
199
160
212


200
197
208
204
203
206
207
208
199200
201-202
200201
217
212216
209-210
() 114
() 31
31
137-144
32
31
32
32
() 33
34
104
160-161
161
161
60
190-193
20
200
( ) 160
108
125-126
32
14
- () 40
212
200
(= ) 31,114
91
238

60-62
63

53
8
8
8
37

287
3738
37-38
38
8
8
8
8
14
227
228
,
162
206
201
53
200
^ ) 111
124
186-188
( )
11
20
21
6873
13
198
200
201
200
208
208
209
210211
223226
209-210
91
103
104106
102103
() 66
218223

( ) 200
91
( ) 156-160

8,9,53
8,9,53
24
26
24
25

288
56
39
39
42
43
41
, 4142
44
42
228
229
106109

15
15
181182

9
10
912
( )

49
51

189
189
190
112
() 199

2627
27
91
9192
9192
95100
92
() 100-101
94
106-109
93
94
91
11
12
() 214
()
47
77

237

56
212
200
185

188



207
237
158

189190

130
237
227-239
181
210-212
156
156
158160
158
156
157
201
237

19
238-239
18

172-177

() 238-239
39
() 234-235

25
() 50
194-195
200201
217

224226
130136
237
() 234236
228231
228

Оценить