Codeforce 515C. Drazil and Factorial(字符串思维题)
2020-10-14 20:59
381 查看
【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; }
相关文章推荐
- codeforces 515C. Drazil and Factorial
- 【codeforces 515C】Drazil and Factorial
- 515C. Drazil and Factorial
- Codeforces-515C-Drazil and Factorial
- CodeForces 515C. Drazil and Factorial
- C. Drazil and Factorial
- CF Drazil and Factorial (打表)
- Codeforces Round #292 (Div. 2) C. Drazil and Factorial(贪心YY)
- Codeforces Round #292 (Div. 2)——C——Drazil and Factorial
- C. Drazil and Factorial
- Codeforces Round #292 (Div. 1)---A. Drazil and Factorial
- codeforce-231B--- Magic, Wizardry and Wonders (思维+构造)
- codeforces#292-C - Drazil and Factorial-数学规律题
- CF_292_C_Drazil and Factorial_数学
- C. Drazil and Factorial
- Codeforces Round #292 (Div. 2) C. Drazil and Factorial(贪心)
- Codeforces Round #292 (Div. 2) C. Drazil and Factorial(贪心)
- Codeforces Round #292 (Div. 1)A. Drazil and Factorial 构造
- C. Drazil and Factorial
- 【CodeForces 513C】Drazil and Factorial