#K95087. Smallest Integer with Digit Product
Smallest Integer with Digit Product
Smallest Integer with Digit Product
Given an integer \( n \), determine the smallest integer \( m \) such that the product of the digits of \( m \) equals \( n \). Formally, find the minimum \( m \) satisfying
\( \prod_{d \in digits(m)} d = n \)
where digits(m) represents the collection of decimal digits in \( m \). If no such \( m \) exists, output \(-1\). Note that when \( n \) is a single digit (i.e., \( 1 \le n \le 9 \)), the answer is defined as \( n+10 \) (for example, if \( n = 5 \), then \( m = 15 \) since \( 1 \times 5 = 5 \)).
inputFormat
The input consists of a single line containing an integer \( n \) (it can be positive, zero, or negative).
outputFormat
Output the smallest integer \( m \) whose digits multiply to \( n \), or output \(-1\) if no such integer exists.
## sample5
15