- 最后登录
- 2021-4-20
- 在线时间
- 598 小时
- 阅读权限
- 40
- 注册时间
- 2009-3-5
- 积分
- 1843
- 帖子
- 1468
- 精华
- 1
- UID
- 79281
- 性别
- 男
- 积分
- 1843
- 帖子
- 1468
- 精华
- 1
- UID
- 79281
- 性别
- 男
|
我写了个程序算了下,确实有三组解
(4, 43), (6, 29), (7, 22)
- #!/usr/bin/python3
- START = tuple((i, j)
- for i in range(2, 91)
- for j in range(i, 91)
- if i + j > 11 and i * j < 260)
- def mem(f):
- d = {}
- def g(*args):
- if args in d:
- return d[args]
- else:
- d[args] = f(*args)
- return d[args]
- return g
- @mem
- def A0(sum):
- return tuple(filter(lambda p: p[0] + p[1] == sum, START))
- @mem
- def B0(product):
- return tuple(filter(lambda p: p[0] * p[1] == product, START))
- @mem
- def B1(product):
- B = []
- for p in B0(product):
- if known_A_tB(A0(p[0] + p[1]), B0):
- B.append(p)
- return tuple(B)
- @mem
- def A2(sum):
- A = []
- for p in A0(sum):
- if (known_B_tA(B0(p[0] * p[1]), A0)
- and not known_B(B1(p[0] * p[1]))):
- A.append(p)
- return tuple(A)
- @mem
- def B3(product):
- B = []
- for p in B1(product):
- if not known_A(A2(p[0] + p[1])):
- B.append(p)
- return tuple(B)
- @mem
- def A4(sum):
- A = []
- for p in A2(sum):
- if known_B(B3(p[0] * p[1])):
- A.append(p)
- return tuple(A)
- def known_A(A):
- return len(A) == 1
- def known_B(B):
- return len(B) == 1
- def known_A_tB(A, Bn):
- for p in A:
- if known_B(Bn(p[0] * p[1])):
- return False
- return True
- def known_B_A(B, An):
- for p in B:
- if not known_A(An(p[0] + p[1])):
- return False
- return True
- def known_B_tA(B, An):
- for p in B:
- if known_A(An(p[0] + p[1])):
- return False
- return True
- def test(x, y):
- A = A0(x + y)
- if known_A(A) or not known_A_tB(A, B0):
- return False
- B = B0(x * y)
- if known_B(B) or not known_B_tA(B, A0):
- return False
- B = B1(x * y)
- if known_B(B):
- return False
- if known_B_A(B, A2) or known_B_tA(B, A2):
- return False
- A = A2(x + y)
- if known_A(A):
- return False
- B = B3(x * y)
- if not known_B(B):
- return False
- A = A4(x + y)
- if not known_A(A):
- return False
- return True
- if __name__ == '__main__':
- a = []
- for p in START:
- if test(p[0], p[1]):
- a.append(p)
- print(a)
复制代码 |
|