1
2
3
4
5
6
7
8
9
10
11
12
12 1 11 2 10 3 9 4 8
5 7 6 6
13 3 4
3 · 13
1 x < y 11 y + 1
x y + 1 12 1 x
1 n n(n + 1)/2
12 · 13
2
y(y + 1)
2
+
x(x + 1)
2
1 12
12·13
4
(y x) · (y + x + 1) = 6 · 13
y x < y + x + 1 y + x + 1 = 13 y x = 6 x
y y = 9 x = 3
10 3
i {1, . . . , 12}
x
i
x
i
= 1 i
x
i
= 0
X
i
i · x
i
=
X
i
i
!
/2
12 (1, 2) (2, 3) (12, 1) 2
x
i
x
i mod 12+1
exactly(2)
i
(x
i
6= x
i mod 12+1
)
x
1
= 1 i {4, . . . , 9}
1
2
3
4
5
6
7
8
9
10
11
12
X
i
i · x
i
=
X
i
i
!
/2
exactly(2)
i
(x
i
6= x
i mod 12+1
)
x
i
{0, 1} i {1, . . . , 12}
model solveIt;
set i:=1..12;
binary variable x{i};
constraint A: sum{i} i
*
x = (sum{i} i)/2;
constraint B: exactly(2){i} (x[i] <> x[i%#i+1]);
solve;
Write('The numbers%3d are on one side\n',{i|x} i);
end;