Codeforces #292C. Drazil and Factorial 数学
2016-02-28 13:32
337 查看
题目
题目链接:http://codeforces.com/problemset/problem/515/C题目来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=105944#problem/D
简要题意:F(n)F(n)为各位的阶乘之积,求一最大的n′,F(n′)=F(n)n',F(n')=F(n)。
题解
数学题,分情况去讨论或者一步步分解。首先对于质数或11的阶乘是无法分解的。
能够分解成越多数字越好,然后就去分解就行了,都是分解成若干质数。
代码
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <stack> #include <queue> #include <string> #include <vector> #include <set> #include <map> #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second using namespace std; typedef long long LL; typedef vector<int> VI; typedef pair<int,int> PII; // head int cnt[15]; char s[25]; void add(int x) { if (x == 0 || x == 1) return; if (x==2 || x==3 || x==5 || x== 7) { cnt[x]++; } else if (x == 4) { cnt[2] += 2, cnt[3]++; } else if (x == 6) { cnt[5]++, cnt[3]++; } else if (x == 8) { cnt[7]++, cnt[2] += 3; } else { cnt[7]++, cnt[2]++, cnt[3] += 2; } } int main() { int n; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) { add(s[i] - '0'); } for (int i = 9; ~i; i--) { while (cnt[i]--) putchar(i + '0'); } puts(""); return 0; }
相关文章推荐
- 计算音频帧的播放时间(音频码流 音频帧)
- linux下查找包含关键字的文件
- Android学习笔记day9
- HDU1541 Stars(树状数组)
- 1016: [JSOI2008]最小生成树计数
- 微信-弹幕是怎么搞出来的,看svg!
- [LeetCode]62 不同的路径总数
- 线性插值(linear interpolation)
- JSP—九大隐式对象之pageContext
- 关于用struts2框架中iframe对应的jsp页面的不到action的值的问题
- 其他IO流
- 认识数据仓库建设意义
- 从Eclipse迁移到Android Studio
- a标签点击后的虚线框
- JAVA通过ftp远程获取文件并压缩
- Leetcode ☞ 319. Bulb Switcher ☆ brain teaser
- Oracle数据库SQL优化
- 2016/02/28 codes
- 数据的离散化
- 有一种设计风格叫RESTful