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

析:最大,那么首先是位数最多,然后是前面尽量大,所以我们要让位数最大,那么就转化,2-2, 3-3, 4-322, 5-5, 6-53, 7-7, 8-7222, 9-733.

然后排序就好了。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 5e4 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m; }
string str[] = {"", "", "2", "3", "322", "5", "53", "7", "7222", "7332"};
string s; int main(){
while(scanf("%d", &n) == 1){
cin >> s;
string ans = "";
for(int i = 0; i < n; ++i)
ans += str[s[i]-'0'];
sort(ans.begin(), ans.end());
for(int i = ans.size()-1; i >= 0; --i)
printf("%c", ans[i]);
printf("\n");
}
return 0;
}

CodeForces 515C Drazil and Factorial (水题)的更多相关文章

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

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

  2. CodeForces 515C. Drazil and Factorial

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

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

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

  4. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  6. codeforces 696A Lorenzo Von Matterhorn 水题

    这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...

  7. CodeForces 589I Lottery (暴力,水题)

    题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...

  8. Codeforces Gym 100286G Giant Screen 水题

    Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...

  9. codeforces 710A A. King Moves(水题)

    题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...

随机推荐

  1. 集训第四周(高效算法设计)H题 (贪心)

    Description   Most financial institutions had become insolvent during financial crisis and went bank ...

  2. UVA 230 Borrowers (STL 行读入的处理 重载小于号)

    题意: 输入若干书籍和作者名字,然后先按作者名字升序排列,再按标题升序排列,然后会有3种指令,BORROW,RETURN, SHELVE. BORROW 和 RETURN 都会带有一个书名在后面,如: ...

  3. <mongoose>……find与findOne的区别……//

    mongoose中的 find 和 findOne 都是用来查找指定表的数据的 find指的是查找指定表的所有数据,返回的是数组 User.find().then((result)=>{ con ...

  4. Discuz论坛广告横幅大图在百度app内无法显示,百度app默认开启了广告屏蔽

    问题由来 前段时间搭的一个Discuz论坛上挂了2个广告横幅,网站的话收录还不错,然后客户就反应百度app上无法看到横幅. 由于我没有下载百度app,看不到效果我将信将疑,因为电脑,手机浏览器都是ok ...

  5. clip-path实现loading圆饼旋转效果以及其他方法

    一.loading效果 二.clip-path css中的剪切clip-path属性是CSS Masking模块的一部分. 矩形 clip-path:inset(top right bottom le ...

  6. 谷歌浏览器添加Bing搜索引擎:

    谷歌浏览器添加Bing搜索引擎:   https://www.bing.com/search?q=%s&pc=MOZI&form=MOZLBR  

  7. [SPOJ7258]Lexicographical Substring Search

    [SPOJ7258]Lexicographical Substring Search 试题描述 Little Daniel loves to play with strings! He always ...

  8. 姓名与ID(codevs 1027 未结题)

    题目描述 Description 有N个人,各自有一个姓名和ID(别名).每个人的姓名和ID都没有重复.这些人依次进入一间房间,然后可能会离开.过程中可以得到一些信息,告知在房间里的某个人的ID.你的 ...

  9. 【ZJOI2017 Round1练习】D8T3 stone(Nim游戏)

    题意: 思路:与其类似的题是HDU5996 HDU5996为判定性问题,稍加改动就可以用来统计方案数 ..]of longint; v,cas,i,j,ans,tmp,n,s,k:longint; b ...

  10. jquery datatable显示隐藏子表

    <table id="parentTable">     <thead>         <tr>             <th> ...