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 ...
随机推荐
- Android 与H5之间的js交互
之前项目做过一些Android和Html5之间js交互方面的东西,今天有时间就总结一下: 一.为什么要进行js交互: 为了方便原生开发和Html之间数据传递,在静态页面的情况下可以改变原生开发的页面: ...
- Jenkins maven仓库地址 和 手动修改maven 版本
① Jenkins maven仓库地址,一般情况会在:/root/.m2/repository/* ② 手动修改maven 版本,Apache 下载指定的maven版本,然后解压后copy到指定目录即 ...
- java List的相关工具类
1. <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</ar ...
- less (css预处理)
用法 1. 必须在head内 2. 样式文件必须先加载 <head> <meta charset='utf-8'> <link rel="stylesheet/ ...
- 【题解】国家集训队礼物(Lucas定理)
[国家集训队]礼物(扩展Lucas定理) 传送门可以直接戳标题 172.40.23.20 24 .1 答案就是一个式子: \[ {n\choose \Sigma_{i=1}^m w}\times\pr ...
- PAT 1060. 爱丁顿数(25)
英国天文学家爱丁顿很喜欢骑车.据说他为了炫耀自己的骑车功力,还定义了一个“爱丁顿数”E,即满足有E天骑车超过E英里的最大整数E.据说爱丁顿自己的E等于87. 现给定某人N天的骑车距离,请你算出对应的爱 ...
- 动态创建selectjs 操作select和option
1.动态创建select function createSelect(){ var mySelect = document.createElement("select"); myS ...
- UITableViewCell高度自适应的关键点
iOS开发中对于UITableViewCell高度自适应的文章已经很多很多,但如果cell内容比较复杂,刚使用autolayout配置自使用时还是总不能一次性成功. KEY POINT 这里只说设置的 ...
- 【leetcode刷题笔记】Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For ...
- mongodb同步
mongodb同步 py-mongo-sync MongodbSync mongodb 的一个同步工具,具备将一个数据源上的数据,同步到其它 mongodb 上,支持: mongos -> (m ...