a = int(input())div_num = 2cnt=0if (a==1):print("1")else:while a!=1:if (a%div_num)==0:cnt += 1a //= div_numelse:if cnt:print("%d^%d * "%(div_num, cnt),end='') if cnt>1 else print("%d * "%(div_num),end='')div_num += 1cnt=0print("%d^%d"%(div_num, cnt)) if cnt>1 else print("%d"%(div_num))
先處理2,後面都只剩奇數 處理時間從200ms => 89ms