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

把2-9每个数打表,看最多能分解成哪几个的阶乘,然后直接替换,最后排序输出。
 #include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cctype>
#include <queue>
#include <map>
using namespace std; const int SIZE = ; bool comp(const int a,const int b); char RULE[][] = {{""},{""},{""},{""},{""},{""},{""},{""},{""},{""}};
int main(void)
{
int n;
char s[SIZE];
char ans[SIZE] = {'\0'}; cin >> n;
cin >> s;
for(int i = ;s[i];i ++)
if(s[i] != '' && s[i] != '')
strcat(ans,RULE[s[i] - '']);
sort(ans,ans + strlen(ans),comp);
cout << ans << endl; return ;
} bool comp(const int a,const int b)
{
return a > b;
}

CF Drazil and Factorial (打表)的更多相关文章

  1. [codeforces 516]A. Drazil and Factorial

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

  2. 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 ...

  3. CodeForces 515C. Drazil and Factorial

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

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

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

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

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

  6. CF Drazil and His Happy Friends

    Drazil and His Happy Friends time limit per test 2 seconds memory limit per test 256 megabytes input ...

  7. CF Drazil and Date (奇偶剪枝)

    Drazil and Date time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

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

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

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

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

随机推荐

  1. nyoj 127 星际之门(一)

    星际之门(一) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 公元3000年,子虚帝国统领着N个星系,原先它们是靠近光束飞船来进行旅行的,近来,X博士发明了星际之门 ...

  2. codeforces 653A Bear and Three Balls

    A. Bear and Three Balls time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  3. 用6个字符写出任意的Javascript代码

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用6个字符写出任意的Javascript代码.

  4. MFC 应用、模板、框架、文档、视图 的关系

    从该对象 如何访问其他对象 全局函数 调用全局函数AfxGetApp可以得到CWinApp应用类指针 应用 AfxGetApp()->m_pMainWnd为框架窗口指针:用CWinApp::Ge ...

  5. CSS 文本格式

    整理自:(http://www.w3school.com.cn/css/css_text.asp) Text Color 颜色属性被用来设置文字的颜色. 颜色是通过CSS最经常的指定: 十六进制值 - ...

  6. MPAndroidChart

    该库的可扩展性强,代码相对规范,最近一次更新有很大改进,如果不喜欢AChartEngine的过于复杂可以考虑在此库的基础上开发自己的图表类. linechart 填充式lineChart 单条线的Li ...

  7. JavaScript DOM对象和JQuery对象相互转换

    1.分析源代码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...

  8. 关于MVC中DropDownListFor的一个bug

    如以下代码: //后台 代码 ViewData["source_type"] = new List<SelectListItem> { "}, "} ...

  9. Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) B. Bear and Blocks 水题

    B. Bear and Blocks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/573/pr ...

  10. Codeforces Gym 100286I iSharp 水题

    Problem I. iSharpTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...