3111. Smallest Number With Given Digit Product

Medium
Math
Greedy

Description

Hints

Hint 1
Find the prime factors of <code>n</code>.
Hint 2
If there is a prime factor <code>p</code> such that <code>p >= 11</code>, the answer is <code>-1</code>. Since there are no digits whose products equal <code>p</code>.
Hint 3
Factors <code>5</code> and <code>7</code> should be included in the answer since their product with any number bigger than <code>1</code> is a 2-digit number.
Hint 4
For factors <code>2</code> and <code>3</code>, we group every three <code>2</code> into an <code>8</code> and every two <code>3</code> into a <code>9</code>.
Hint 5
For any leftover <code>2</code> or <code>3</code>, check all the possible combinations.

Statistics

Acceptance
43.3%
Submissions
3,100
Accepted
1,342