Codeforce 515C. Drazil and Factorial(字符串思维题)
【CodeForces】C. Drazil and Factorial
题目链接:Click Here
题意:找一个最大的数,使得每个位的阶乘的乘积与给定数相同。
首先將 2~9 轉成這樣(0,1為空):
2 -> 2 (2! = 2不能以其他方式組成)
3 -> 3 (3! = 6不能以其他方式組成)
4 -> 322 (4! = 24 可以用3! * 2! * 2! 組成)
5 -> 5 (5! = 120)
6 -> 53
7 -> 7
8 -> 7222
9 ->7332
只要想到这个就很简单了,利用字符串存储,去相应替代每一个即可
// Author : RioTian
// Time : 20/10/14
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, i, Fac[10] = {0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
string a[] = {"", "", "2", "3", "322", "5", "53", "7", "7222", "7332"};
string s, ss = "";
int main() {
// freopen("in.txt","r",stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> s;
for (i = 0; i < n; ++i)
ss += a[s[i] - '0'];
sort(ss.rbegin(), ss.rend());
cout << ss << endl;
}
Codeforce 515C. Drazil and Factorial(字符串思维题)的更多相关文章
- CodeForces 515C. Drazil and Factorial
C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 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/problemset/problem/515/C 题目意思:给出含有 n 个只有阿拉伯数字的字符串a(可能会有前导0),设定函数F(a) = 每个 ...
- codeforces 515C C. Drazil and Factorial(水题,贪心)
题目链接: C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 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 516]A. Drazil and Factorial
[codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define ...
- PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记
PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...
- codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题
http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...
- little w and Soda(思维题)
链接:https://ac.nowcoder.com/acm/contest/297/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...
- ACM思维题训练 Section A
题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...
随机推荐
- 【Javaweb】Servlet四 | ServletConfig类|ServletContext类
ServletConfig类是Servlet程序的配置信息类. ServletConfig类的三大作用 1.可以获取Servlet程序的别名servlet-name的值 System.out.prin ...
- Codeforces Round #656 (Div. 3) E. Directing Edges(拓扑排序)
题目传送门 首先发现初始图五有向环的话那么肯定是"YES",否则是"NO".然后找到一种满足要求地建树规则即可.这里采用拓扑排序建树,先dfs找出目前点的拓扑序 ...
- StackGres 数据库平台工程,使用 Citus + Patroni 创建生产级高可用分布式 PostgreSQL 分片集群
系列 StackGres, 可私有部署的云原生数据库平台工程 StackGres 数据库平台工程功能介绍与快速上手 StackGres 1.6 数据库平台工程集群配置管理(K8S Pods/Postg ...
- 我用 AI 写的《JavaScript 工程师的 Python 指南》电子书发布啦!
关于本书 你好,我是 luckrnx09,一名靠 React 恰饭的前端工程师,很高兴向你介绍我的第一本开源电子书<JavaScript 工程师的 Python 指南>. 本书的内容完全免 ...
- 一款开源免费美观的WinForm UI控件库 - ReaLTaiizor
前言 今天推荐一款基于MIT license开源.免费.美观的.NET WinForm UI控件库:ReaLTaiizor. 什么是WinForm? WinForm是一个传统的桌面应用程序框架,它基于 ...
- 数字孪生系统如何整合CesiumJS?整合后会产生怎样的化学反应?
数字孪生有关的项目中,智慧城市一直是一个比较重要的类型,但是这类智慧城市项目往往包含了大量的GIS相关数据,例如倾斜摄影.DEM.DOM.地形数据等.这时,将GIS系统融合进数字孪生系统的需求就出现了 ...
- vscode下载
vscode下载 想下载官网可以直接去官网下载(速度超慢~) 百度网盘链接: 链接:https://pan.baidu.com/s/14DfWI5b2HA_J_kHBcu8JQw?pwd=yyds 提 ...
- influxdb 进行数据删除和修改
本文为博主原创,转载请注明出处: 1.条件删除数据 InfluxDB 只支持基于时间的删除操作. 可以使用 DELETE 语句来删除指定时间范围内的数据.例如,以下的 SQL 语句将删除 measur ...
- 建议收藏备查!MySQL 常见错误代码说明
先给大家看几个实例的错误分析与解决方案. 1.ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data ...
- zabbix常用监控项
https://blog.csdn.net/xkjcf/article/details/78559273?locationNum=10&fps=1 agent.ping #agent是否在线 ...