题目链接: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. 初始化Git的配置

    如何使用Git上传项目代码到github http://blog.csdn.net/llf369477769/article/details/51917557

  2. Struts2-----面试题汇总

    1.struts2框架中,从用户发出请求到获得响应整个过程的流转图 FilterDispatcher --> ActionProxy-->Configuration Manager--&g ...

  3. dotnetbar入门

    1.下载dotnetbar组件 2.工具箱引用 3.项目引用 4.开始工作 //此处Form完整的名称是System.Windows.Forms.Form,表示FrmMain窗体类是继承于System ...

  4. 9月12日JavaScript脚本语言

    JS脚本语言 JS脚本语言全称JavaScript,是网页里面使用的脚本语言,也是一门非常强大的语言. 一.基础语法 1.注释语法 单行注释:// 多行注释:/**/ 2.输出语法 ①alert(信息 ...

  5. Java递归算法——汉诺塔问题

    //================================================= // File Name : Tower_demo //-------------------- ...

  6. 使用ASP.NET Web Api构建基于REST风格的服务实战系列教程【三】——Web Api入门

    系列导航地址http://www.cnblogs.com/fzrain/p/3490137.html 前言 经过前2节的介绍,我们已经把数据访问层搭建好了,从本章开始就是Web Api部分了.在正式开 ...

  7. nodeJS接受post传过来的参数

    1.nodeJs接受Post传递的参数需要通过绑定两个事件来获取, querystring = require("querystring");  1 app.post('/comm ...

  8. php preg_match 过滤字符

    $f = preg_match("/g3watches/",$date[0]['desc']); if ($f='1') { $this->error(L('不好意思,输入有 ...

  9. memcached命令行操作详解,命令选项的详细解释

    连接到memcached命令行下:  telnet 127.0.0.1 11211 1.set / add / replace : 格式:<command> <key> < ...

  10. 为什么要做url encode

    因为 url 对字符有限制,比如把一个邮箱放入 url,就需要使用 urlencode 函数,因为 url 中不能包含 @ 字符.