python,#2 8 10 超时!!!!!!!!!!!
查看原帖
python,#2 8 10 超时!!!!!!!!!!!
1003348
Gojosatoru楼主2023/8/14 21:49
import math
li = []
cout = 0
for s in range(3, 10000, 2):
    chucun = 0
    s_sqrt = int(math.sqrt(s)) + 1
    for i in range(3, s_sqrt):
        chucun = s / i
        if chucun == int(chucun):
            cout += 1
    if cout == 0:
        li.append(s)
    cout = 0
li.append(2)
li.sort()


cout = 0
s = int(input())

for i in range(4, s+1, 2):
    result = []
    for num in li:
        if num < i:
            cout += 1
    for j in range(cout):
        num = i-(li[j])
        if num in li:
            result.append(li[j])
    cout = 0
    print(str(i)+'='+str(result[0])+'+'+str(max(result)))



整体思路是吧10000以内的质数算出来再一个一个的试

2023/8/14 21:49
加载中...