UVa 993
From Algorithmist
Contents |
[edit] 993 - Product of digits
[edit] Summary
Given a number N, determine the smallest positive integer whose digits have a product of N. (0<=N<=10^9)
[edit] Explanation
For most numbers, you need to break the number down into factors below 10, then print the digits in ascending order. The smallest number tries to have as many large factors as possible (i.e. maximum number of 9s, followed by maximum 8s, etc.), and the result is printed in ascending order.
[edit] Gotchas
- The output must be a positive integer for all values of N.
[edit] Notes
[edit] Implementations
[edit] Optimizations
[edit] Input
3 1 10 123456789
[edit] Output
1 25 -1
[edit] References
- Reference 1