这段代码完成时间太长了。我已经尽我所能让它工作并让它运行了一个小时。我正在尝试解决这个问题:
令 a、b、c 和 n 为正整数。如果 a+b+c = 19*97 并且 a+n = bn = c/n 计算 a 的值。
这是我的代码:
from itertools import *
import gc
gc.disable()
a_list = []
ah = 0
b_num = 0
c_num = 0
number_of_solutions = 0
for a, b, c, n in product(range(1, 19*97), repeat=4):
if a+b+c == 19*97 and a+n == b-n and b-n == c/n and a+n == c/n:
a_num = a
b_num = b
c_num = c
a_list.append(a)
number_of_solutions = number_of_solutions + 1
else:
pass
print a_num+b_num+c_num
print a_list
print number_of_solutions
请帮忙!谢谢!