Codeforces Round #292 (Div. 2) C. Drazil and Factorial
题目链接: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的更多相关文章
- 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 ...
- 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. ...
- 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 ...
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)
题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...
- 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 ...
- Codeforces Round #292 (Div. 1) C - Drazil and Park
C - Drazil and Park 每个点有两个值Li 和 Bi,求Li + Rj (i < j) 的最大值,这个可以用线段树巧妙的维护.. #include<bits/stdc++. ...
- 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 ...
- Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造
A. Drazil and Factorial 题目连接: http://codeforces.com/contest/516/problem/A Description Drazil is play ...
- Codeforces Round #292 (Div. 2)
A. Drazil and Date 无算法,判断(s - (a + b)) % 2是否为零,若零,表示在s步内还能走向其他的地方并且回来 否则,都是No #include <cstdio> ...
随机推荐
- vs2013安装闪退及vs2010 vs2013打开时提示 未能完成的操作 及vs2013安装时出现图片后闪退
vs2013打开时提示如上图,vs2010只有 未能完成的操作 这样的提示. 这时.net 4.0开发的程序打开也毫无反应,应该是.net framework出了问题.查看控制面板-卸载程序,发现 ...
- 安卓官方ViewPager与android.support.design.widget.TabLayout双向交互联动切换 。
该TabLayout的功用,简单的说,就是当用户在该TabLayout的选项卡子item中选择触摸时候,文字和下方的指示器横条滑动指示.android.support.design.widget.Ta ...
- thinkphp新增
$m = M('content'); //与 $m = new Model('content')效果一样 $date = array( 'username' => I('username', ...
- ubuntu网络设置
修改/etc/network/interfaces文件sudo gedit /etc/network/interfaces 贴出我的eth0设置,自己看情况修改:# The primary netwo ...
- owin中间件
public class HelloWorldOptions { public HelloWorldOptions() { IncludeTimestamp = true; Name = " ...
- 使用EntityFramework6.1的DbCommandInterceptor拦截生成的SQL语句
开始 EF6.1也出来不少日子了,6.1相比6.0有个很大的特点就是新增了System.Data.Entity.Infrastructure.Interception 命名空间,此命名空间下的对象可以 ...
- maven 入门
Apache Maven 入门篇 ( 上 ) 作者:George Ma 写这个 maven 的入门篇是因为之前在一个开发者会的动手实验中发现挺多人对于 maven 不是那么了解,所以就有了这个想法.这 ...
- js 字符串分割成字符串数组 遍历数组插入指定DOM里 原生JS效果
使用的TP3.2 JS字符串分割成字符串数组 var images='{$content.pictureurl} ' ;结构是这样 attachment/picture/uploadify/20141 ...
- 缓存算法(页面置换算法)-FIFO、LFU、LRU
在前一篇文章中通过leetcode的一道题目了解了LRU算法的具体设计思路,下面继续来探讨一下另外两种常见的Cache算法:FIFO.LFU 1.FIFO算法 FIFO(First in First ...
- jquery自定义函数的多种方法
在jquery中自定义函数你会吗?今天抽时间写了几个,个人感觉还不错,喜欢的朋友可以了解下 复制代码 代码如下: //方法定义 $.windowbox = { //定义一个方法aa aa: fun ...