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

Tests(0/0):


Code:

def find_chicken_solutions(N): solutions = [] for x in range(N // 5 + 1): # 公鸡最多为N/5 for y in range((N - x) // 3 + 1): # 母鸡的数量 z = N - x - y # 计算小鸡的数量 if z % 3 == 0 and 5 * x + 3 * y + z // 3 == N: solutions.append((x, y, z)) break # 找到一种解后,跳出当前循环继续寻找其他解 return solutions def print_solutions(solutions): if not solutions: print('None') else: for index, (x, y, z) in enumerate(solutions, start=1): print(f'{index}: {x},{y},{z}') N = int(input()) solutions = find_chicken_solutions(N) print_solutions(solutions)


Run Info:

  File "Main.py", line 16
    print(f'{index}: {x},{y},{z}')
                                ^
SyntaxError: invalid syntax