Run ID:85276
提交时间:2024-07-16 20:52:29
def buy_chickens(N): solutions = [] for x in range(N // 5 + 1): # 公鸡数量不能超过总金额除以5 for y in range(N // 3 + 1): # 母鸡数量不能超过总金额除以3 z = N - x - y # 小鸡数量 if 5 * x + 3 * y + (1/3) * z == N: # 检查总价是否等于N solutions.append((x, y, z)) return solutions def print_solutions(solutions): if not solutions: print("None") else: for i, (x, y, z) in enumerate(solutions, start=1): print(f"{i}: {x}, {y}, {z}")