Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
85294 彭士宝 百钱买百鸡II Python3 Compile Error 0 MS 0 KB 734 2024-07-16 21:20:28

Tests(0/0):


Code:

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)


Run Info:

  File "Main.py", line 15
    print(f'{index}: {roosters},{hens},{chicks}')
                                               ^
SyntaxError: invalid syntax