Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
85124 sh25_wangtaojie 三连击 Python3 通过 1341 MS 70500 KB 1167 2026-03-06 15:05:07

Tests(2/2):


def permutations(arr): if len(arr) <= 1: return [arr] result = [] for i in range(len(arr)): rest = arr[:i] + arr[i+1:] for p in permutations(rest): result.append([arr[i]] + p) return result def solve(A, B, C): digits = [1, 2, 3, 4, 5, 6, 7, 8, 9] results = [] # 生成所有排列 for perm in permutations(digits): # 构造三个三位数 num1 = perm[0] * 100 + perm[1] * 10 + perm[2] num2 = perm[3] * 100 + perm[4] * 10 + perm[5] num3 = perm[6] * 100 + perm[7] * 10 + perm[8] # 检查比例关系 if num1 * B == num2 * A and num1 * C == num3 * A: results.append((num1, num2, num3)) # 按照第一个数字升序排列 results.sort() return results def main(): # 读取输入 A, B, C = map(int, input().split()) # 求解 solutions = solve(A, B, C) # 输出结果 if not solutions: print("No!!!") else: for sol in solutions: print(sol[0], sol[1], sol[2]) if __name__ == "__main__": main()


测评信息: