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.

Sample test(s)
Input
4
1234
Output
33222
Input
3
555
Output
555
Note

In the first case,

真的说,这道题目是比较简单的,只是我的想法有点问题。

我做的过程太过于复杂了!在中间操作过程已经使结果超过 long long

而JS相当于在中间过程有简单的优化,是我没想到的,我把每个数还原的过于简单了

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <ctype.h>
using namespace std;
#define LL long long int main()
{
int n;
char num[];
int cnt[] = {};
int bit[];
while(scanf("%d%*c", &n) != EOF)
{
int tag = ;
for(int i = ; i < n; i++)
{
scanf("%c", &num[i]);
cnt[num[i] - '']++;
} for(int i = ; i < n; i++)
{
if(cnt[] && num[i] == '')
{
bit[tag++] = ;
bit[tag++] = ;
bit[tag++] = ;
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
bit[tag++] = ;
bit[tag++] = ;
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
bit[tag++] = ;
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
cnt[]--;
}
else if(cnt[] && num[i] == '')
{
bit[tag++] = ;
cnt[]--;
}
}
sort(bit, bit+tag);
for(int i = tag-; i >= ; i--)
{
cout << bit[i];
}
cout << endl;
}
return ;
}

CodeForces 515C. Drazil and Factorial的更多相关文章

  1. codeforces 515C. Drazil and Factorial 解题报告

    题目链接:http://codeforces.com/problemset/problem/515/C 题目意思:给出含有 n 个只有阿拉伯数字的字符串a(可能会有前导0),设定函数F(a) = 每个 ...

  2. CodeForces 515C Drazil and Factorial (水题)

    题意:给出含有 n 个只有阿拉伯数字的字符串a,设定函数F(a) = 每个数字的阶乘乘积 .需要找出 x,使得F(x) = F(a),且组成 x 的数字中没有0和1.求最大的 x 为多少. 析:最大, ...

  3. CodeForces 516A Drazil and Factorial 动态规划

    原文链接http://www.cnblogs.com/zhouzhendong/p/8990592.html 题目传送门 - CodeForces 516A 题意 对于一个正整数$x$,$f(x)=x ...

  4. codeforces 515C C. Drazil and Factorial(水题,贪心)

    题目链接: C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

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

    C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  6. [codeforces 516]A. Drazil and Factorial

    [codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define  ...

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

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

  8. CF Drazil and Factorial (打表)

    Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  9. 【codeforces 515C】Drazil and Factorial

    [题目链接]:http://codeforces.com/contest/515/problem/C [题意] 定义f(n)=n这个数各个位置上的数的阶乘的乘积; 给你a; 让你另外求一个不含0和1的 ...

随机推荐

  1. ecshop后台 计划任务

    计划任务定时清理掉设置后的内容 主要针对单表删除(日志,):对于多表删除,不太好用(订单+订单商品+订单日志) 结构: 1.计划任务语言包:languages\zh_cn\cron\ 2.php文件: ...

  2. Storm 单机版环境搭建

    1 需要安装的软件 要使用storm首先要安装以下工具:python.zookeeper.zeromq.jzmq.storm 1.1 安装zeromq wget http://download.zer ...

  3. python基础知识

    由于python的灵活性,赋值前无需强调变量的数据类型,并且变量的数据类型在后期的操作过程中还可以改变,故不介绍关键字,直接定义方法及可以调用的方法. I  基本数据类型 一.字符串 1.使用单引号或 ...

  4. CentOS6.3 编译安装LAMP(2):编译安装 Apache2.2.25

    所需源码包: /usr/local/src/Apache-2.2.25/httpd-2.2.25.tar.gz 编译安装 Apache2.2.25 #切换到源码目录 cd /usr/local/src ...

  5. 浅谈ASM中的SLB

    接触Azure几个月,总想写点什么,迟迟没有动笔,一是怕自己技术粗鄙,写的东西会令人捧腹,二是工作原因,时间比较匆忙,在此再次声明,以下写的东西都是我个人看法,若有不足,请多多包涵!!! 情景是这样的 ...

  6. C和指针 第十章 结构和联合 (一)

    结构体: 聚合数据类型是指,能够同时存储超过一个的单独数据,C语言中有两个聚合数据类型,数组和结构体.数组中储存的类型必须相同,元素通过下标和指针引用来访问的. 结构体也是一些值的集合,但是结构体中每 ...

  7. Ubuntu 14.04 LTS 安装Docker

    Docker官方是有很详细的安装文档(https://docs.docker.com/engine/installation/ubuntulinux/),这里做了一个Ubuntu 14.04 LTS中 ...

  8. JQuery EasyUI DataGrid获取当前行或选中行

    1.获取当前选中行,如果没有选中行,则返回 null var row = $('#gridID').datagrid('getSelected'); 2.获取当前所有选中行数据,返回元素记录的数组数据 ...

  9. jquery.SuperSlide.js只需要调用一个插件就能实现网页大部分特效--推荐

    很棒的一个插件,http://www.superslide2.com/

  10. JS正则表达式元字符

    https://segmentfault.com/a/1190000002471140