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

Copy
4
1234
output

Copy
33222
input

Copy
3
555
output

Copy
555
Note

In the first case, 

题意 给出数x,得出x各位数阶乘的乘积;求得出的各位数乘积和与x得出的各位数阶乘的乘积相等的最大数

先打表ch[i] F[i]=F[p]最大值p,排序,反转

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
int n;
scanf("%d",&n);
string str;
cin>>str;
string str1 = "";
string ch[]={"","","","","","","","","",""};
for(int i = ; i < n; i++){
str1 += ch[str[i]-''];
}
sort(str1.begin(),str1.end());
reverse(str1.begin(),str1.end());
cout<<str1<<endl;
return ;
}

Codeforces Round #292 (Div. 2) C. Drazil and Factorial 515C的更多相关文章

  1. Codeforces Round #292 (Div. 2) C. Drazil and Factorial

    题目链接:http://codeforces.com/contest/515/problem/C 给出一个公式例如:F(135) = 1! * 3! * 5!; 现在给你一个有n位的数字a,让你求这样 ...

  2. Codeforces Round #292 (Div. 1) C. Drazil and Park 线段树

    C. Drazil and Park 题目连接: http://codeforces.com/contest/516/problem/C Description Drazil is a monkey. ...

  3. Codeforces Round #292 (Div. 1) B. Drazil and Tiles 拓扑排序

    B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a f ...

  4. Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)

    题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...

  5. Codeforces Round #292 (Div. 1) - B. Drazil and Tiles

    B. Drazil and Tiles   Drazil created a following problem about putting 1 × 2 tiles into an n × m gri ...

  6. Codeforces Round #292 (Div. 1) C - Drazil and Park

    C - Drazil and Park 每个点有两个值Li 和 Bi,求Li + Rj (i < j) 的最大值,这个可以用线段树巧妙的维护.. #include<bits/stdc++. ...

  7. Codeforces Round #292 (Div. 2) D. Drazil and Tiles [拓扑排序 dfs]

    传送门 D. Drazil and Tiles time limit per test 2 seconds memory limit per test 256 megabytes Drazil cre ...

  8. Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造

    A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...

  9. Codeforces Round #292 (Div. 2)

    A. Drazil and Date 无算法,判断(s - (a + b)) % 2是否为零,若零,表示在s步内还能走向其他的地方并且回来 否则,都是No #include <cstdio> ...

随机推荐

  1. Datagridview 实现二维表头和行合并

    借鉴别人的,改了改,没用timer using System;using System.Collections.Generic;using System.ComponentModel;using Sy ...

  2. ios Alamofire网络插件的使用

    pod 'Alamofire' import Alamofire let headers:HTTPHeaders = [ "aa":"bb" ] let par ...

  3. Spring的分模块开发的配置

    参考:Spring学习笔记-Spring的分模块开发的配置 在加载配置文件的时候,加载多个 例如把applicationContext.xml配置文件中的关于集合配置的部分剪切到application ...

  4. CMOS

    CMOS是Complementary Metal Oxide Semiconductor(互补金属氧化物半导体)的缩写.它是指制造大规模集成电路芯片用的一种技术或用这种技术制造出来的芯片,是电脑主板上 ...

  5. zabbix的MariaDB数据库改变存储位置

    #创建 mkdir /公司缩写/mysql   #停止数据库服务 systemctl status mariadb.service systemctl stop mariadb.service   # ...

  6. DjangoModels

    传智博客的python的笔记 数据库配置 ORM简介 MVC框架中包括一个重要的部分,就是ORM,它实现了数据模型与数据库的解耦,即数据模型的设计不需要依赖于特定的数据库,通过简单的配置就可以轻松更换 ...

  7. 洛谷 P1220 关路灯 题解

    Description 有 $n$ 盏路灯,每盏路灯有坐标(单位 $m$)和功率(单位 $J$).从第 $c$ 盏路灯开始,可以向左或向右关闭路灯.速度是 $1m/s$.求所有路灯的最少耗电.输入保证 ...

  8. log4j简单的使用

    1.引入log4j.jar包 2.在类中使用 package com.donghai.log4j; import org.apache.log4j.Logger; public class LogTe ...

  9. 思科WLC5508上传定制Portal展示模版

    1. 登录Cisco设备,获取模板样例登录cisco WLC设备后点击help,打开帮助文档Wireless Tab-->Web Login Page-->External Web Aut ...

  10. 了解DocumentFragment 给我们带来的性能优化

    首先我们需要了解 DocumentFragment 是什么? w3c 上面的详细解释:link here 我把关键点写下来了: DocumentFragment 节点不属于文档树,继承的 parent ...