515C. Drazil and factorial

Source: Internet
Author: User
Tags time limit
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;

}



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.