编程语言
首页 > 编程语言> > P5723 【深基4.例13】质数口袋-2022.02.01(python3实现)

P5723 【深基4.例13】质数口袋-2022.02.01(python3实现)

作者:互联网

【深基4.例13】质数口袋 - 洛谷

"""

P5723 【深基4.例13】质数口袋-2022.02.01(python3实现)
https://www.luogu.com.cn/problem/P5723

"""

lena=0

cnt=0

prime=[1 for i in range(100010)]

lena=int(input())

prime[1]=0
prime[0]=0

for i in range(2,100010):

            if prime[i]==1:

                        j=i*2
                        while j<100010:
                                    prime[j]=0
                                    j+=i

for i in range (2,100010):

            if prime[i]==1:
                        if lena>=i:

                                    print(i)

                                    lena-=i

                                    cnt+=1
                        else:
                                    break

print(cnt)


标签:prime,13,01,质数,深基,lena,cnt
来源: https://blog.csdn.net/dllglvzhenfeng/article/details/122765540