題目

解答

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
x = ans = int(input())
output=''
while True:
for i in range(2,x+1):
if ans == i:
break
if x%i == 0:
output += str(i)+' '
x = x//i
break
if x == 1 or x == ans:
break
if x == ans:
print(ans)
else:
outputlist = output.split()
m = 1
outputlist1 = outputlist.copy()
outputlist2 = []
for i in range(len(outputlist)-1):
if outputlist[i] == outputlist[i+1]:
m += 1
outputlist1.remove(outputlist[i+1])
else:
outputlist2.append('^'+str(m))
m = 1
outputlist2.append('^'+str(m))
output = ''
for i in range(len(outputlist1)):
output += ' '+outputlist1[i]+outputlist2[i]
output = output.replace(' ',' * ')
output = output.replace('^1','')
output1 = ''
for i in range(3,len(output)):
output1+=output[i]
print(output1)

這題我寫的跟垃圾一樣,
但我也得重寫了,
建議不要看。