布尔系统(用于C ++ / C#/ JAVA)布尔、系统、JAVA

2023-09-12 21:24:22 作者:英雄的少女梦

我如何编程解决这种类型的系统:

How can I programatically resolve this type of system :

A = !B
B = !C
D = !B
E = !A
E = !B

这样我就可以通过替换获得 A = C = D(3) E = B(2) 。我只需要2组的数量。如果这是不可能得到2组,我显示错误消息。

so I can get by substituting A = C = D (3) and E = B (2). I only need the number of the 2 groups. If it's not possible to get 2 groups, I display an error message.

推荐答案

在的情况下,这是不关闭,一个傻瓜,从我的answer在previous问题:

In case, this is not closed as a dupe, from my answer in your previous question:

要解决的形式方程

X 1 =不是X 3

X1 = NOT X 3

X 5 =不是X 2

X5 = NOT X 2

形成具有节点的图形为X 我和连接X 我和X Ĵ当且仅当方程x 我 =不是X Ĵ出现。

Form a graph with nodes as Xi and connecting Xi and X j iff the equation Xi = NOT X j appears.

现在使用广度优先搜索尝试2色图。

Now try to 2-colour the graph using Breadth First Search.

 
精彩推荐
图片推荐