1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| a, b = map(int, input().split()) c = 0 for x in range(1, a + 1): y = (a - 4 * x) / 3 if y > 0: if 4 * x + 3 * x * 2 + 2 * y + 2 * 4 * y == b: m = 3 * x n = 2 * y print(f"A笼中有鸡{3*x}只,兔{x}只") print(f"B笼中有鸡{int(y)}只,兔{int(2*y)}只") print(f"两笼共有鸡{int(3*x+y)}只,兔{int(x+2*y)}只") c = 1 if c == 0: print("无合适的组合方案")
|