a = int(input())
num = 2
while(int(a>=num)):
count = 0
while(int(a%num)==0):
count+=1
a = int(a/num)
if(a==1):
print(num)
else:
if(count>=2):
print(num,"^",count,sep='', end=' * ')
elif(count==1):
print(num,sep='', end=' * ')
num+=1
a = int(input())
num = 2
while(int(a>=num)):
count = 0
while(int(a%num)==0):
count+=1
a = int(a/num)
if(a==1):
print(num)
else:
if(count>=2):
print(num,"^",count,sep='', end=' * ')
elif(count==1):
print(num,sep='', end=' * ')
num+=1
更 AC了
忘記考慮尾數是次方項
但0.9s 好不爽 要怎麼壓秒