C. Drazil and factorial time limit per test 2 seconds memory limit per test megabytes input standard input output Stan Dard output
Drazil is playing a math game with Varda.
Let's define for positive an integer x as a product of factorials of its digits. For example,.
First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number is possibly start with leading zeroes. Then they should find maximum positive number x satisfying following both conditions:
1. x doesn ' t contain neither digit 0 nor digit 1.
2. =.
Help friends find such number. Input
The first line contains an integer n (1≤n≤15)-the number of digits in a.
The second line contains n digits of a. There is at least one digit in a so is larger than 1. Number A may possibly contain leading zeroes. Output
Output a maximum possible integer satisfying the conditions above. There should is no zeroes and ones in this number decimal representation. Sample Test (s) Input
4
1234
Output
33222
Input
3
555
Output
555
Note
In the first case,
Test instructions: Look at the last picture to understand, two numbers open each one to the same as the output of factorial. Output can not have 1, input may be the first bit is 0
Analysis: Enumeration 0 to 9 can replace what Bai ...
#include <bits/stdc++.h>
using namespace std;
String arr[]={"", "", "2", "3", "322", "5", "", "7", "7222", "7332"};
int main ()
{
long long n,t;
cin>>t;
cin>>n;
String s= "";
while (n>0)
{
s+=arr[n%10];
n/=10;
}
Sort (S.rbegin (), S.rend ());
cout<<s;
}