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

Tests(0/0):


Code:

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


Run Info:

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