题目链接:

C. Drazil and Factorial

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Drazil is playing a math game with Varda.

Let's define  for positive 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 may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two 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 that is larger than 1. Number a may possibly contain leading zeroes.

Output

Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.

Examples
input
4
1234
output
33222
input
3
555
output
555
Note

In the first case, 

思路:把数拆一下就是很简单了;

AC代码:

#include <bits/stdc++.h>
using namespace std;
char s[];
int flag[];
int main()
{
int n;
scanf("%d",&n);
memset(flag,,sizeof(flag));
scanf("%s",s);
for(int i=;i<n;i++)
{
if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
flag[]+=;
}
else flag[s[i]-'']+=;
}
for(int i=;i>;i--)
{
//cout<<"@"<<flag[i]<<endl;
while(flag[i])
{
printf("%d",i);
flag[i]-=;
}
}
}

最新文章

  1. MediaElement 的两种模式
  2. PCA 主成分分析(Principal components analysis )
  3. findByExample(Object exampleEntity)方法得到的List判断是否为空,不可用(lis != null)
  4. C# WinForm控件之Dock顺序调整
  5. XUnit学习
  6. 杭电oj 1016 Prime Ring Problem
  7. vs2010常用快捷方式
  8. javascript 函数学习
  9. 通过纯Java代码从excle中读取数据(为.xlsx文件)
  10. TCP carries HTTP data in order, and without corruption
  11. kafka 0.10.2 cetos6.5 集群部署
  12. synchronized Lock用法
  13. jmockit学习
  14. vue生命週期
  15. C++解题报告 : 迭代加深搜索之 ZOJ 1937 Addition Chains
  16. 跨域调用接口的方法之一:$.ajaxSetup()
  17. BZOJ3537 : [Usaco2014 Open]Code Breaking
  18. C#缓存流的使用浅析
  19. Visual Studio Ultimate 2013
  20. 转:如何捕获winform程序全局异常?

热门文章

  1. WEBserver、应用程序server、HTTPserver差别
  2. NYOJ-欧几里得
  3. Java static关键字特点
  4. github-readme.md-格式
  5. 将非递减有序排列(L L1)归并为一个新的线性表L2 线性表L2中的元素仍按值非递减
  6. SQLServer2008 统计表占用空间
  7. One Person Game(概率+数学)
  8. maven assembly 配置详解
  9. POJ 2856 Y2K Accounting Bug【简单暴力】
  10. ElasticSearch(二十六)修改分词器及定制自己的分词器