2017-08-23 17:57:34 +08:00

27 lines
608 B
Python

from tools import number_theory
def get(x, y, lst, dct):
if x > y:
return dct[(x, y)]
return lst[x]
def count(limit):
prime = list(number_theory.make_prime(1000))
lst = [0, 0, 1, 1, 1, 2]
dct = {(4, 3): 1, (4, 2): 1, (5, 3): 1, (5, 2): 0}
num = 5
while lst[-1] <= limit:
num += 1
tale = 0
for p in prime:
if p > num:
break
tale += get(num - p, p, lst, dct)
dct[(num, p)] = tale
if num in prime:
tale += 1
lst.append(tale)
return len(lst) - 1
print(count(5000))