如题:
python代码如下:
for a in range(1,5):
for b in range(0,9):
for c in range(0,9):
abc = a*100 + b*10 + c
t1 = abc % 8 == 0 #甲说abc可以被2整除3次
t2 = abc % 9 == 0 #乙说abc可以被3整除2次
t3 = abc % 7 == 0 #丙说abc可以被7整除
t4 = a + b + c == 15 #丁说abc之和是15
if t1 is True and t2 is True and t3 is True:
print ("丁说谎,abc = ", abc)
elif t1 is True and t2 is True and t4 is True:
print ("丙说谎,abc = ", abc)
elif t1 is True and t3 is True and t4 is True:
print ("乙说谎,abc = ", abc)
elif t2 is True and t3 is True and t4 is True:
print ("甲说谎,abc = ", abc)
运行程序得到结果:
乙说谎,abc = 168