Challenge
In this task you would be given an integer N you have to output all non-trivial power representation of the integer.
Non-trivial power means the base and exponent are > 1
The input N is given in a single line,the inputs are terminated by EOF.The number of inputs would not exceed 10000 values.
The challenge is to implement the fastest solution so that it can process a maximum of 10000 values as fast as possible.
Input
1745041
1760929
1771561
1852321
1868689
1874161
1885129
1907161
1953125
113795717542678488615120001
113795717546049421004105281
Output
1745041 = 1321^2
1760929 = 1327^2
1771561 = 11^6 121^3 1331^2
1852321 = 1361^2
1868689 = 1367^2
1874161 = 37^4 1369^2
1885129 = 1373^2
1907161 = 1381^2
1953125 = 5^9 125^3
113795717542678488615120001 = 10667507560001^2
113795717546049421004105281 = 10667507560159^2
Constraints
- N is less than 30 digits long to test your favorite integer factorization algorithm ;-)
- Assume that for ever input N,at-least one non-trivial power representation is possible.
- You can use any language of your choice
- Fastest solution,with the most efficient time complexity wins!