LCC '21 Contest 1 S1 - Password Please

View as PDF

Submit solution


Points: 5
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

Alan wants a new phone password but he's rather picky.

Firstly, he wants the password to contain 5 digits. Secondly, he wants the sum of the digits to equal X. Thirdly, he wants the product of the digits to equal Y. Finally, he does not want the password to contain the digit 0.

Please help Alan find the lexicographically smallest password that satisfies his conditions.

Input Specification

The first line and only line will contain two space-separated integers, X (5 \le X \le 45) and Y (1 \le Y \le 59049).

Output Specification

Output the lexicographically smallest password that satisfies Alan's conditions. It is guaranteed that a solution exists.

Sample Input

15 120

Sample Output

12345

Explanation

42531, 32415, 23145 etc. also satisfy Alan's requirements, but 12345 is the lexicographically smallest solution.


Comments

There are no comments at the moment.