Composite Factorization
InterviewTime limit1sMemory limit1024 MB
Factor N into a product of composite numbers, choosing the lexicographically smallest such sequence, or report that none exists.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Greedy, Brute force
- Solved
- No attempts yet
Problem
Prime factorization expresses a natural number as a product of primes. Yeondu, who hates number theory with a passion, trembles at the mere sight of a prime, so instead she invented "composite factorization," which expresses a natural number as a product of composite numbers.
The composite factorization of a natural number is defined as a sequence that satisfies all of the following conditions.
- Every element of is a composite number. (A composite number is an integer that has a divisor other than and itself.)
- The product of all elements of is .
However, Yeondu realized that may have several composite factorizations, or none at all. Write a program that performs composite factorization of on Yeondu's behalf. If several results are possible, choose the lexicographically smallest one.
Input
The input is given as follows.
Output
Among the composite factorizations of , print the elements of the lexicographically smallest sequence in order, separated by spaces.
If no composite factorization is possible, print -1 instead.
Constraints
- is an integer.
Hint
The precise definition of a sequence being lexicographically smaller than a sequence is that one of the following holds.
- There exists an such that and .
- and .