题目链接:http://codeforces.com/contest/515/problem/C

给出一个公式例如:F(135) = 1! * 3! * 5!;

现在给你一个有n位的数字a,让你求这样一个x,满足x中没有0和1,F(a) = F(x),然后就是x要最大.

当x的位数比a多或者从高位开始x的数某一位要大于a的某一位,然后第二种显然是不可能的,所以我们寻找如何把a变长的方法.

例如数字

4! = 1 * 2 * 3 * 4

=3! * 2 * 2

=3! * 2! * 2!

所以当a中包含数字4时,我们可以通过把4拆成322来变大,同理:

F(6) = F(53)

F(8) = F(7222)

F(9) = F(7332)

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,A[];
char str[];
int main()
{
while(scanf("%d",&n)!=EOF)
{
scanf("%s",str);
int f = ;
for(int i = ;i < n;++i)
{
if(str[i] == '')
{
A[f++] = ;
A[f++] = ;
A[f++] = ;
}
else if(str[i] == '')
{
A[f++] = ;
A[f++] = ;
}
else if(str[i] == '')
{
A[f++] = ;
A[f++] = ;
A[f++] = ;
A[f++] = ;
}
else if(str[i] == '')
{
A[f++] = ;
A[f++] = ;
A[f++] = ;
A[f++] = ;
}
else
{
if(str[i]-'' > )
A[f++] = str[i] - '';
}
}
sort(A,A+f);
for(int i = f-;i >= ;--i)
printf("%d",A[i]);
puts("");
}
return ;
}

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

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

  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. 回调函数通俗解析(之前看了很久都不理解,今天终于ok啦)

    自学jquery的时候,看到一英文词(Callback),顿时背部隐隐冒冷汗.迅速google之,发现原来中文翻译成回调.也就是回调函数了.不懂啊,于是在google回调函数,发现网上的中文解释实在是 ...

  2. Yocto开发笔记之《快速入门,环境搭建 & 编译》(QQ交流群:519230208)

    开了一个交流群,欢迎爱好者和开发者一起交流,转载请注明出处. QQ群:,为避免广告骚扰,申请时请注明 “开发者” 字样 ======================================== ...

  3. glade2支持C++代码的输出(2)

    今天更新了一个BaseObject的代码:BaseObject.002.zip 同时将glade2生成C++代码的代码进行了调整,基于2.12.2的补丁为:cpp_out_2.patch.tar.xz ...

  4. SMO推导和代码-记录毕业论文4

    SMO的数学公式通过Platt的论文和看这个博客:http://www.cnblogs.com/jerrylead/archive/2011/03/18/1988419.html,大概弄懂了.推导以后 ...

  5. Windows XP SP3 Professional 微软(MSDN)官方原版系统

    Windows XP SP3 Professional 微软(MSDN)官方原版系统 Windows XP(版本号:5.1,开发代号:Whistler)是微软公司推出供个人电脑使用的操作系统,其RTM ...

  6. JavaScript学习笔记——变量和数据类型

    一.javascript命名规范 1. 严格区分大小写 2. 变量的命名必须以字母或 _或 $开头,余下的部分可以是任意的字母,数字,或者是 _或者是$ 3.不能用关键字或者是保留字命名. 4.jav ...

  7. Nginx+HTTPS(SSL/TLS)

    环境 首先确保机器上安装了openssl和openssl-devel rpm -qa | grep openssl #yum install openssl #yum install openssl- ...

  8. SCI答复审稿人的策略和答复信的写作技巧

    SCI论文被录用的最后一步 –---答复审稿人的策略和答复信的写作技巧 [好文转载] : 一篇稿子从酝酿到成型历经艰辛,投出去之后又是漫长的等待,好容易收到编辑的回信,得到的往往又是审稿人不留情面的一 ...

  9. SSL/TLS加密传输与数字证书解读

    什么是ssl? secure socket layer(ssl)协议最初由netscape企业发展,现已成为网络用来鉴别网站和网页浏览者身份,以及在浏览器使用者及网页服务器之间进行加密通讯的全球化标准 ...

  10. Yii2 事务

    $transaction = $connection->beginTransaction(); try { // ... executing other SQL statements ... $ ...