-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKASUB1.PAS
46 lines (41 loc) · 851 Bytes
/
KASUB1.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{ mk 2003 }
{ n skaiciu isskaidome i dvi grupes, kad ju sumos lygios }
type
Tmas = array [1 .. 100] of boolean;
var
mas : Tmas;
n, puse : integer;
ok : boolean;
procedure lisk (nuo, kiek, sum : integer; var mas : Tmas);
var
ck : Integer;
begin
if ok then exit;
if kiek = n div 2 then
begin
if sum = puse then
begin
write (sum, ': ');
for ck := 1 to n do
if mas [ck] then write (ck, ' ');
writeln;
ok := true;
end;
exit
end;
for ck := nuo to n do
begin
mas [ck] := true;
lisk (ck + 1, kiek + 1, sum + ck, mas);
mas [ck] := false
end
end;
begin
writeln (' ======================');
n := 50;
fillchar (mas, sizeof (mas), 0);
mas [1] := true;
ok := false;
puse := (n + 1) * n div 4;
lisk (2, 1, 1, mas);
end.