【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(字符串思维题)的更多相关文章

  1. CodeForces 515C. Drazil and Factorial

    C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. CodeForces 515C Drazil and Factorial (水题)

    题意:给出含有 n 个只有阿拉伯数字的字符串a,设定函数F(a) = 每个数字的阶乘乘积 .需要找出 x,使得F(x) = F(a),且组成 x 的数字中没有0和1.求最大的 x 为多少. 析:最大, ...

  3. codeforces 515C. Drazil and Factorial 解题报告

    题目链接:http://codeforces.com/problemset/problem/515/C 题目意思:给出含有 n 个只有阿拉伯数字的字符串a(可能会有前导0),设定函数F(a) = 每个 ...

  4. codeforces 515C C. Drazil and Factorial(水题,贪心)

    题目链接: C. Drazil and Factorial time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. 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 ...

  6. [codeforces 516]A. Drazil and Factorial

    [codeforces 516]A. Drazil and Factorial 试题描述 Drazil is playing a math game with Varda. Let's define  ...

  7. PJ考试可能会用到的数学思维题选讲-自学教程-自学笔记

    PJ考试可能会用到的数学思维题选讲 by Pleiades_Antares 是学弟学妹的讲义--然后一部分题目是我弄的一部分来源于洛谷用户@ 普及组的一些数学思维题,所以可能有点菜咯别怪我 OI中的数 ...

  8. codeforces ~ 1009 B Minimum Ternary String(超级恶心的思维题

    http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 seco ...

  9. little w and Soda(思维题)

    链接:https://ac.nowcoder.com/acm/contest/297/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  10. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

随机推荐

  1. jmeter-jsr223取样器的使用

    相比于BeanShell 取样器,JSR223取样器具有可大大提高性能的功能(编译)如果需要,一定要使用JSR223取样器编写脚本是更好的选择!!! 属性描述名称:显示的此取样器的描述性名称,可自定义 ...

  2. java-EasyExcel模板导出

    前言:  需求:根据自定义模板导出Excel,包含图片.表格,采用EasyExcel 提示:EasyExcel请使用 3.0 以上版本, 对图片操作最重要的类就是 WriteCellData<V ...

  3. SpringBoot实现Flyway的Callback回调钩子

    背景 产品迭代使用CI/CD升级过程中,需要对不同发布环境的不同产品版本进行数据库迭代升级,我们在中间某次产品迭代时加入了Flyway中间件以实现数据库结构的自动化升级. 需求 由于是迭代过程中加入的 ...

  4. [CF568E] Longest Increasing Subsequence

    题目描述 Note that the memory limit in this problem is less than usual. Let's consider an array consisti ...

  5. C++ Qt开发:CheckBox多选框组件

    Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍CheckBo ...

  6. 安装MacOS - 初学者系列 - 学习者系列文章

    上次安装了个VMWare Workstation 17.5.0的精简注册版,昨天打开软件,发现竟然支持了MacOS操作系统了,所以就想把安装的过程记录一下. 1. 准备虚拟机: 1) 下载精简版: 从 ...

  7. Linux配置成代理服务器

    简介: 代理服务器(Proxy Server)是一种位于计算机网络中的中间服务器,它充当了客户端和目标服务器之间的中介,用于转发客户端请求并获取目标服务器的响应.代理服务器的主要功能包括以下几点: 什 ...

  8. Bert-vits2-2.3-Final,Bert-vits2最终版一键整合包(复刻生化危机艾达王)

    近日,Bert-vits2发布了最新的版本2.3-final,意为最终版,修复了一些已知的bug,添加基于 WavLM 的 Discriminator(来源于 StyleTTS2),令人意外的是,因情 ...

  9. 【Python】【OpenCV】定位条形码(一)

    关于二维码和条形码的检测和识别,在OpenCV中已经有提供了对应的API,cv2.QRCodeDetector() | cv2.barcode_BarcodeDetector() ,相关的实现极其简单 ...

  10. SpringBoot-MybatisPlus-Dynamic(多数据源)-springboot-mybatisplus-dynamic-duo-shu-ju-yuan-

    title: SpringBoot-MybatisPlus-Dynamic(多数据源) date: 2021-05-07 13:58:06.637 updated: 2021-12-26 17:43: ...