Python#3#6WA求助
查看原帖
Python#3#6WA求助
1227790
MC_xjhjdA楼主2024/9/16 12:08
n=int(input())
if n<=2:
    print('1=1')
    exit()
a,b=1,1
for x in range(n-2):
    a,b=b,a+b
l=[f'{b}=']
def ossa(n): #欧拉筛
    m=int(n**0.5)
    status=[True]*(m+1)
    primes=[]
    for x in range(2,m+1):
        if status[x]:
            if n%x==0:
                return x
            primes.append(x)
        for y in primes:
            if y*x>m:
                break
            status[y*x]=False
            if x%y==0:
                break
    return n
te=b
while te!=1:
    tem=te
    te=ossa(te)
    l.append(f'*{te}')
    te=tem//te
l[1]=l[1].replace('*','')
print(''.join(l))
2024/9/16 12:08
加载中...