codeforces 515C C. Drazil and Factorial(水题,贪心)
题目链接:
time limit per test
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
In the first case,
思路:把数拆一下就是很简单了;
AC代码:
#include <bits/stdc++.h>
using namespace std;
char s[];
int flag[];
int main()
{
int n;
scanf("%d",&n);
memset(flag,,sizeof(flag));
scanf("%s",s);
for(int i=;i<n;i++)
{
if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
}
else if(s[i]=='')
{
flag[]+=;
flag[]+=;
flag[]+=;
}
else flag[s[i]-'']+=;
}
for(int i=;i>;i--)
{
//cout<<"@"<<flag[i]<<endl;
while(flag[i])
{
printf("%d",i);
flag[i]-=;
}
}
}
codeforces 515C C. Drazil and Factorial(水题,贪心)的更多相关文章
- CodeForces 515C Drazil and Factorial (水题)
题意:给出含有 n 个只有阿拉伯数字的字符串a,设定函数F(a) = 每个数字的阶乘乘积 .需要找出 x,使得F(x) = F(a),且组成 x 的数字中没有0和1.求最大的 x 为多少. 析:最大, ...
- 【codeforces 515C】Drazil and Factorial
[题目链接]:http://codeforces.com/contest/515/problem/C [题意] 定义f(n)=n这个数各个位置上的数的阶乘的乘积; 给你a; 让你另外求一个不含0和1的 ...
- [codeforces 516]A. Drazil and Factorial
[codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
随机推荐
- LINQ to Tree - A Generic Technique for Querying Tree-like Structures,包含遍历WPF VisualTree
https://www.codeproject.com/Articles/62397/LINQ-to-Tree-A-Generic-Technique-for-Querying-Tree#generi ...
- SQL SERVER 2008查看sql执行的时间
set statistics profile onset statistics io onset statistics time ongo<这里写上你的语句...>goset statis ...
- c/c++的一些小知识点3
---恢复内容开始--- ---恢复内容结束---
- 【BZOJ1125】[POI2008]Poc hash+map+SBT
[BZOJ1125][POI2008]Poc Description n列火车,每条有l节车厢.每节车厢有一种颜色(用小写字母表示).有m次车厢交换操作.求:对于每列火车,在交换车厢的某个时刻,与其颜 ...
- ArcGIS API for js Legend(图例)
1.说明 有关怎么把ArcGIS API for js部署到IIS上,请参考我上面的写的博客https://www.cnblogs.com/net064/p/10302660.html 2.运行效果 ...
- On the importance of initialization and momentum in deep learning
Ilya Sutskever1 ilyasu@google.com James Martens jmartens@cs.toronto.edu George Dahl gdahl@cs.toronto ...
- 我的Android进阶之旅------>WindowManager.LayoutParams介绍
本文转载于: http://hubingforever.blog.163.com/blog/static/171040579201175111031938/ 本文参照自: http://develop ...
- java面向对象入门之带参方法创建
/* Name :创建带参的方法 Power by :Stuart Date:2015.4.25 */ //创建Way类 class Way{ //Way类成员的基本变量 int add1=123; ...
- python基础12 ---函数模块2
函数模块 一.sys函数模块详解 1.sys.argv[x] 功能:从程序外部接受参数,接收的参数个数可以是多个,在程序内部sys.argv吧这些外部参数转换成元组的形式,然后以索引x的方式在内部取出 ...
- 查看mysql支持的存储引擎
查看mysql支持的存储引擎 show engines\G;