2905.Drazil and Factorial

Time Limit: 1s Memory Limit: 256MB

Drazil is playing a math game with Varda.Let's define 2905_1.png for positive integer x as a product of factorials of its digits. For example, 2905_2.png.First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:1. x doesn't contain neither digit 0 nor digit 1.2. 2905_1.png = 2905_3.png.Help friends find such number.

Input Format(From the terminal/stdin)

Input The first line contains an integer n (1 \le n \le 15) - the number of digits in a.The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.

Output Format(To the terminal/stdout)

Output Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.

Sample Input 1

Copy
4
1234
 \n
    \n

Sample Output 1

Copy
33222
     \n

Sample Input 2

Copy
3
555
 \n
   \n

Sample Output 2

Copy
555
   \n

Hints

In the first case, 2905_4.png

Submit

请先 登录

© 2025 FAQs