#11891: Python AC :)


yusing (Stack Overflow)


while True:

    try:

        _input = int(input())

        factorscount = 0

        factor = 2

        output = ""

        while(_input > 1):

            while(_input%factor == 0):

                _input = _input // factor

                factorscount += 1

            if(factorscount > 1):

                output += str(factor)+"^"+str(factorscount) 

            if(factorscount == 1):

                output += str(factor)

            if(_input % (factor+1) == 0)and(output != ""):

                output += " * "

            factorscount = 0

            factor += 1

        print(output)

    except EOFError:

        break

#11892: Re:Python AC :)


yusing (Stack Overflow)


 

補充說明:

while True: 代表程式永不終止

except EOFError: break 代表遇到EOF錯誤(輸入的值無效)時程式終止

_input 代表輸入的數值

output 代表輸出的句子

factorscount 代表算式中有多少個同樣的因數

factor 代表指因數的值