Problem here
Problem
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:
X doesn ' t contain neither digit 0 nor digit 1.
=
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.
Sampleinput
4
1234
Output
33222
Input
3
555
Output
555
Solution
Here's the answer.
#include <iostream>#include <string>#include <algorithm>using namespace STD;stringArr[] = {"0","0","2","3","322","5","Only","7","7222","7332"};BOOLcmpChar&a,Char&B) {returna > B;}intMain () {intNCin>> N;stringInputCin>> input;stringresult =""; for(inti =0; I < input.length (); i++) {if(Input[i]! =' 0 '&& Input[i]! =' 1 ') {result + = arr[input[i]-' 0 ']; }} sort (Result.begin (), Result.end (), CMP);cout<< result << Endl;return 0;}
"Codeforces" C. Drazil and factorial