题解 | #查找组成一个偶数最接近的两个素数#
查找组成一个偶数最接近的两个素数
http://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9
while True:
try:
N = int(input())
su = set()
if N == 2:
su.add(N)
else:
for ii in range(2,N+1):
if ii == 2:
su.add(ii)
else:
flag = 0
for jj in list(su):
if ii%jj == 0:
flag = 1
break
if flag == 0:
su.add(ii)
g = list(su)
O = []
for ii in g:
h = N-ii
if h in g:
O.append([ii,h])
u = min([abs(d[1]-d[0]) for d in O])
for e in O:
if e[1]-e[0] == u:
print(e[0])
print(e[1])
except:
break