Run ID:134184
提交时间:2025-10-25 22:16:44
def main(): N = int(input("请输入正整数N (N≤100): ")) results = [] # 枚举所有可能的四元组 for a in range(2, N + 1): a_cube = a ** 3 for b in range(2, a): b_cube = b ** 3 for c in range(b, a): c_cube = c ** 3 for d in range(c, a): d_cube = d ** 3 if b_cube + c_cube + d_cube == a_cube: results.append((a, b, c, d)) # 按题目要求排序:a从小到大,a相同则按b、c、d排序 results.sort() # 输出结果 for a, b, c, d in results: print(f"Cube = {a}, Triple = ({b},{c},{d})") if __name__ == "__main__": main()