ZOJ2562:More Divisors(反素数)
来源:互联网 发布:php 反射类 编辑:程序博客网 时间:2024/05/01 17:36
Everybody knows that we use decimal notation, i.e. the base of our notation is 10. Historians say that it is so because men have ten fingers. Maybe they are right. However, this is often not very convenient, ten has only four divisors -- 1, 2, 5 and 10. Thus, fractions like 1/3, 1/4 or 1/6 have inconvenient decimal representation. In this sense the notation with base 12, 24, or even 60 would be much more convenient.
The main reason for it is that the number of divisors of these numbers is much greater -- 6, 8 and 12 respectively. A good quiestion is: what is the number not exceeding n that has the greatest possible number of divisors? This is the question you have to answer.
Input:
The input consists of several test cases, each test case contains a integer n (1 <= n <= 1016).
Output:
For each test case, output positive integer number that does not exceed n and has the greatest possible number of divisors in a line. If there are several such numbers, output the smallest one.
Sample Input:1020100Sample Output:
61260题意:求n以内因子最多的数
# include <iostream># define ULL unsigned long longusing namespace std;int best, p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; ;ULL ans, n;void dfs(int depth, ULL tmp, int num){ if(depth >= 16) return; if(num > best) { best = num; ans = tmp; } else if(num == best && tmp < ans) ans = tmp; for(int i=1; i<=64; ++i) { if(n / p[depth] < tmp || num > best) break; dfs(depth+1, tmp *= p[depth], num*(i+1)); }}int main(){ while(cin >> n) { ans = ~0ULL; best = 0; dfs(0, 1, 1); cout << ans << endl; } return 0;}
- ZOJ2562:More Divisors(反素数)
- zoj2562--More Divisors(反素数模板)
- zoj2562 More Divisors && CF27E. Number With The Given Amount Of Divisors(反素数)
- More Divisors(反素数)
- zoj2562(反素数)
- zoj2562(反素数)
- More Divisors----反素数
- zoj 2562 More Divisors(反素数)
- ZJU 2562 More Divisors (反素数)
- ZOJ More Divisors 2562 (反素数)
- zoj2562 More Divisors
- ZOJ2562 More Divisors
- hdu4542 && ZOJ2562(反素数)
- ZOJ 2562 More Divisors 解题报告(反素数)
- zoj2562 反素数
- Zoj 2562 More Divisors (反素数)
- zoj 2562 More Divisors(反素数)
- ZOJ 2562 More Divisors 反素数 DFS
- #OSG+VS#06第三周
- HTML的footer置于页面最底部的方法
- 2-SAT——CodeForces #400 D
- AppDelegate代理方法
- leetcode35~Search Insert Position
- ZOJ2562:More Divisors(反素数)
- 关系数据库中的三范式
- Request如何取得客户端Ip
- word中文分词
- redo和undo 详解
- 转
- eclipse 导入tomcat7源码
- 《数据结构和算法》之中缀表达式、后缀表达式转换
- Oracle中的定时任务