是Py不配吗?我都使用欧拉筛了,还是没有过啊!
查看原帖
是Py不配吗?我都使用欧拉筛了,还是没有过啊!
707862
s_a_b_e_ryyds楼主2022/4/13 23:11
from math import sqrt
def hanshu(a,b):
    ls=[True]*(b+1)
    c=int(sqrt(b))+1
    d=2
    while d<c:
        if ls[d]==True:
            for i in range(d+d,b+1,d):
                ls[i]=False
        d+=1
    for i in range(a,b+1):
        j=str(i)
        if j==j[::-1]:
            if ls[i]==True:
                print(j)
a,b=map(int,input().split())
hanshu(a,b)
2022/4/13 23:11
加载中...