#pip install tqdm #python3 xyz.py #遍历从 -limit 到 limit 的所有整数值,寻找满足方程的非零整数解。允许你指定一个开始 (start_limit) 和结束 (end_limit) 的范围。 #v1.1修正进度条的总迭代次数被高估的问题 from tqdm import tqdm def find_solutions(start_limit, end_limit): solutions = [] total_iterations = (end_limit - start_limit + 1) ** 3 with tqdm(total=total_iterations, desc="搜索进度") as pbar: for x in range(start_limit, end_limit + 1): for y in range(start_limit, end_limit + 1): for z in range(start_limit, end_limit + 1): if x == 0 and y == 0 and z == 0: continue # 跳过全零解 if 3*x**3 + 4*y**4 + 7*z**2 == 0: solutions.append((x, y, z)) pbar.update(1) return solutions # 设定搜索范围的开始和结束限制 start_limit = 1 end_limit = 1000 # 你可以根据需要调整这些值 # 寻找解决方案 solutions = find_solutions(start_limit, end_limit) # 打印解决方案 if solutions: print("找到的解决方案:") for solution in solutions: print(solution) else: print("在给定的范围内没有找到解决方案。")