Run ID:85294

提交时间:2024-07-16 21:20:28

def find_chicken_solutions(N): solutions = [] for roosters in range(N // 5 + 1): # 公鸡最多为N/5 for hens in range((N - roosters * 5) // 3 + 1): # 母鸡的数量 chicks = N - roosters - hens # 计算小鸡的数量 if chicks % 3 == 0 and 5 * roosters + 3 * hens + chicks // 3 == N: solutions.append((roosters, hens, chicks)) return solutions def print_solutions(solutions): if not solutions: print('None') else: for index, (roosters, hens, chicks) in enumerate(solutions, start=1): print(f'{index}: {roosters},{hens},{chicks}') N = int(input()) solutions = find_chicken_solutions(N) print_solutions(solutions)