题目链接: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. 一键搭建vpn服务器

    今天花了很多时间搭建vpn服务器,后来找到一篇一键搭建服务器的文章,那叫一个爽,附上链接收藏~~~看开以后要写脚本了 http://www.centoscn.com/image-text/instal ...

  2. 《Java疯狂讲义》(第3版)学习笔记 2 - Java语言的运行机制

    内容 1.高级语言的运行机制 2.Java 语言的运行机制 1.高级语言的运行机制 高级语言主要分为编译型语言和解释型语言两类. 编译型语言是指使用专门的编译器.针对特定平台(操作系统)将高级语言源代 ...

  3. D/A转换器实验

    1.代码: #include<reg52.h>typedef unsigned char u8;typedef unsigned int u16;void delay (u16 num){ ...

  4. mysql常用命令之-用户密码修改

    --创建用户 CREATE USER 'user1'@'localhost' IDENTIFIED BY 'pass1'; GRANT SELECT,INSERT,UPDATE,DELETE ON * ...

  5. HTML学习笔记——图片显示、图片跳转、图片相对路径

    1>显示图片.用a标签实现点击图片跳转.地图标签/点击图片上固定区域跳转 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit ...

  6. DX9资源管理

    http://www.cnblogs.com/cxrs/archive/2013/04/03/D3DResourceManager.html http://kasicass.blog.163.com/ ...

  7. 使用.net Stopwatch class 来分析你的代码

    当我们在调试,优化我们的代码的时候,想知道某段代码的真正的执行时间,或者我们怀疑某段代码,或是某几段代码执行比较慢, 需要得到具体的某段代码的具体执行时间的时候.有一个很好用的类Stopwatch. ...

  8. js实现99乘法表

    实现99乘法表(输出到页面上) * document.write("<table border='1' bordercolor='blue'>"); //循环行 9 f ...

  9. Mysql InnoDB行锁实现方式(转)

    Mysql InnoDB行锁实现方式 InnoDB行锁是通过给索引上的索引项加锁来实现的,这一点MySQL与Oracle不同,后者是通过在数据块中对相应数据行加锁来实现的.InnoDB这种行锁实现特点 ...

  10. Page传回页面的值问题