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> ...
随机推荐
- UVA 11419SAM I AM(输出 最小覆盖点 )
参考博客:如何找取 最小覆盖点集合 题意:R*C大小的网格,网格上面放了一些目标.可以再网格外发射子弹,子弹会沿着垂直或者水平方向飞行,并且打掉飞行路径上的所有目标,计算最小多少子弹,各从哪些位置发射 ...
- Linux 中,如何显示 (gcc)make时实际执行命令
问题: 调试编译问题,如何获取,GCC(或许make)时,实际编译器和链接器正在执行的命令? 解决方法: 方法一:通用方法 使用dry run,如下 $ make -n 这将显示make 命令正在试图 ...
- 将字符串转化为数字(Convert和Parse的用法)
字符串必须是数字,不要超过转换成目标数字类型的范围.超过的话系统也会报错(溢出). static void Main(string[] args) { string s; int i; Console ...
- coreseek 中文搜索和高亮
配置文件 # # Minimal Sphinx configuration sample (clean, simple, functional) # source post { type = mysq ...
- 理解Linux系统/etc/init.d目录和/etc/rc.local脚本
一.关于/etc/init.d 如果你使用过Linux系统,那么你一定听说过init.d目录.这个目录到底是干嘛的呢?它归根结底只做了一件事情,但这件事情非同小可,是为整个系统做的,因此它非常重 ...
- JavaScript学习笔记——对象基础
javascript对象基础 一.名词解释: 1.基于对象 一切皆对象,以对象的概念来编程. 2.面向对象编程(oop Object oriented programming) A.对象 就是人们要研 ...
- sql FOR XML PATH
FOR XML PATH 有的人可能知道有的人可能不知道,其实它就是将查询结果集以XML形式展现,有了它我们可以简化我们的查询语句实现一些以前可能需要借助函数活存储过程来完成的工作.那么以一个实例为主 ...
- YII2操作mongodb笔记(转)
componets配置: 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://test: ...
- memcached的最佳实践方案(转)
基本问题 1.memcached的基本设置 1)启动Memcache的服务器端 # /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 ...
- Criteria 和 DetachedCriteria的区别与使用
Criteria 和 DetachedCriteria 的主要区别在于创建的形式不一样, Criteria 是在线的,所以它是由 Hibernate Session 进行创建的:而 DetachedC ...