选派大学生出国学习,满足以下条件
若赵去,则钱也去。
李,周两人中必有一人去。
钱,孙两人中去且仅去一人
孙,李两人同去或同不去。
若周去,则赵,钱也同去。
代码实现:
ls=[0,1]
#p,赵 q,钱 r,孙 s,李 t,周
for p in ls:
for q in ls:
for r in ls:
for s in ls:
for t in ls:
A=(not p) or q #表示(1):若赵去,则钱也去
B=s or t #表示(2):李,周两人中必有一人去
C=(q and (not r)) or ((not q) and r) #表示(3):钱,孙两人中去且仅去一人
D=(r and s) or ((not r)and(not s)) #表示(4):孙,李两人同去或同不去
E=(not t) or (p and q) #表示(5):若周去,则赵,钱也同去
F=A and B and C and D and E
if F ==1:
print("{},{},{},{},{}".format(p,q,r,s,t))
结果:
0,0,1,1,0
1,1,0,0,1