第一次尝试做Codeforces div2的C题,果然凭现在的智商还是想不出来的
官方题解讲的很清楚:http://codeforces.com/blog/entry/16468
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
bool cmp(char a,char b){
return a>b;
}
char ch[1000];
char ans[1000];
char d[10][100]={
"",
"",
"2",
"3",
"322",
"5",
"53",
"7",
"7222",
"7332"};
int main(){
int m;
while(scanf("%d\n",&m)!=EOF){
memset(ans,'\0',sizeof(ans));
scanf("%s",ch);
for(int i=0;i<m;i++){
if(ch[i]=='0'||ch[i]=='1')
continue;
else{
strcat(ans,d[ch[i]-'0']);
}
}
sort(ans,ans+strlen(ans),cmp);
printf("%s\n",ans);
}
return 0;
}