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

Tests(0/0):


Code:

def find_chicken_solutions(N): solutions = [] for m in range(0, N // 3 + 1): # x = 3m x = 3 * m for k in range(0, (N - x) // 3 + 1): # z = 3k z = 3 * k y = 2 * k - 5 * m if y >= 0 and x + y + z == N: solutions.append((x, y, z)) return solutions def print_chicken_solutions(solutions): if solutions: for i, (x, y, z) in enumerate(solutions, 1): print(f"{i}: {x},{y},{z}") else: print("None") # 输入N N = int(input().strip()) # 找到所有可能的解 solutions = find_chicken_solutions(N) # 打印解 print_chicken_solutions(solutions)


Run Info:

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