CF Drazil and Factorial (打表)
2 seconds
256 megabytes
standard input
standard output
Drazil is playing a math game with Varda.
Let's define
for positive integer x as a product of factorials of its digits. For example,
.
First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:
1. x doesn't contain neither digit 0 nor digit 1.
2.
=
.
Help friends find such number.
The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a.
The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.
Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.
4
1234
33222
3
555
555 把2-9每个数打表,看最多能分解成哪几个的阶乘,然后直接替换,最后排序输出。
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cctype>
#include <queue>
#include <map>
using namespace std; const int SIZE = ; bool comp(const int a,const int b); char RULE[][] = {{""},{""},{""},{""},{""},{""},{""},{""},{""},{""}};
int main(void)
{
int n;
char s[SIZE];
char ans[SIZE] = {'\0'}; cin >> n;
cin >> s;
for(int i = ;s[i];i ++)
if(s[i] != '' && s[i] != '')
strcat(ans,RULE[s[i] - '']);
sort(ans,ans + strlen(ans),comp);
cout << ans << endl; return ;
} bool comp(const int a,const int b)
{
return a > b;
}
CF Drazil and Factorial (打表)的更多相关文章
- [codeforces 516]A. Drazil and Factorial
[codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define ...
- 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 515C. Drazil and Factorial
C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 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 515C C. Drazil and Factorial(水题,贪心)
题目链接: C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- CF Drazil and His Happy Friends
Drazil and His Happy Friends time limit per test 2 seconds memory limit per test 256 megabytes input ...
- CF Drazil and Date (奇偶剪枝)
Drazil and Date time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #292 (Div. 2) C. Drazil and Factorial
题目链接:http://codeforces.com/contest/515/problem/C 给出一个公式例如:F(135) = 1! * 3! * 5!; 现在给你一个有n位的数字a,让你求这样 ...
- codeforces 515C. Drazil and Factorial 解题报告
题目链接:http://codeforces.com/problemset/problem/515/C 题目意思:给出含有 n 个只有阿拉伯数字的字符串a(可能会有前导0),设定函数F(a) = 每个 ...
随机推荐
- 在RHEL5.4 设置KVM(虚拟机)通过桥接器上网
以root身份登录系统,创建桥接器配置文件 #cd /etc/sysconfig/network-scripts/ #cp ifcfg-eth0 ifcfg-br0 #vi ifcfg-br0 桥接器 ...
- 转】Maven学习总结(五)——聚合与继承
原博文出自于: http://www.cnblogs.com/xdp-gacl/p/4058008.html 感谢! 一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1. ...
- Spark RDD概念学习系列之Spark的数据存储(十二)
Spark数据存储的核心是弹性分布式数据集(RDD). RDD可以被抽象地理解为一个大的数组(Array),但是这个数组是分布在集群上的. 逻辑上RDD的每个分区叫一个Partition. 在Spar ...
- 【现代程序设计】【homework-08】
1. 理解C++变量的作用域和生命周期 #include<stdio.h> char * test() { ]="; return s; } main() { puts(test ...
- 软件工程——PairProject
结对编程组员: 马辰 11061178 柴泽华 11061153 1) 照至少一张照片, 展现两人在一起合作编程的情况. 结对编程的优点 1)在编程过程中,任何一段代码都不断地复审,同 ...
- NSLog说明
%@ 对象 %d,%i 整型 (%i的老写法) %hd 短整型 %ld , %lld 长整型 %u 无符整型 %f 浮点型和double型 %0.2f 精度浮点数,只保留两位小数 %x,%X 二进制整 ...
- JSF 2 graphicImage example
In JSF, you can use <h:graphicImage /> tag to render a HTML "img" element. For examp ...
- STL学习系列五:Queue容器
Queue简介 queue是队列容器,是一种“先进先出”的容器. queue是简单地装饰deque容器而成为另外的一种容器. #include <queue> 1.queue对象的默认构造 ...
- sql server 2014内存表
内存数据库,指的是将数据库的数据放在内存中直接操作.相对于存放在磁盘上,内存的数据读写速度要高出很多,故可以提高应用的性能.微软的SQL Server 2014已于2014年4月1日正式发布,SQL ...
- ASP.NET中身份验证的三种方法
Asp.net的身份验证有有三种,分别是"Windows | Forms | Passport",其中又以Forms验证用的最多,也最灵活.Forms 验证方式对基于用户的验证授权 ...