-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrazil and Factorial
More file actions
48 lines (43 loc) · 1.07 KB
/
Drazil and Factorial
File metadata and controls
48 lines (43 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
ArrayList<Integer> list = new ArrayList<Integer>();
String str = br.readLine();
for (int i = 0; i < str.length(); i++) {
int num = Integer.parseInt(str.charAt(i) + "");
if (num >= 2 && num <= 9) {
if (num == 4) {
list.add(3);
list.add(2);
list.add(2);
} else if (num == 6) {
list.add(5);
list.add(3);
} else if (num == 8) {
list.add(7);
list.add(2);
list.add(2);
list.add(2);
} else if (num == 9) {
list.add(7);
list.add(3);
list.add(3);
list.add(2);
} else
list.add(num);
}
}
Collections.sort(list, new Comparator<Integer>() {
@Override
public int compare(Integer o0, Integer o1) {
return o1 - o0;
}
});
for (int i : list)
System.out.print(i);
}
}