ZOJ More Divisors 2562 (反素数)
来源:互联网 发布:手机淘宝开店怎么注册 编辑:程序博客网 时间:2024/05/22 02:39
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
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;typedef unsigned long long ll;const ll INF = (ll)1<<63;ll n;ll ans;int m;int p[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};void dfs(int gen,ll tmp,int num){if(gen>=16)return ;if(num>m){m=num;ans=tmp;}if(num==m&&ans>tmp)ans=tmp;for(int i=1;i<=63;i++){if(n/p[gen]<tmp)break;dfs(gen+1,tmp*=p[gen],num*(i+1));}}int main(){while(scanf("%lld",&n)!=EOF){ans=INF;m=0;dfs(0,1,1);printf("%lld\n",ans);}return 0;}
- zoj 2562 More Divisors(反素数)
- ZOJ More Divisors 2562 (反素数)
- Zoj 2562 More Divisors (反素数)
- zoj 2562 More Divisors(反素数)
- ZOJ 2562 More Divisors 反素数 DFS
- ZOJ 2562 More Divisors 解题报告(反素数)
- ZJU 2562 More Divisors (反素数)
- ZOJ Problem Set - 2562 More Divisors 反素数
- More Divisors(反素数)
- More Divisors----反素数
- ZOJ2562:More Divisors(反素数)
- 反素数应用 ZOJ 2562 More Divisors + Timus OJ 1748. The Most Complex Number
- zoj 2562 More Divisors
- Zoj 2562 More Divisors
- zoj 2562 More Divisors
- zoj 2562 More Divisors
- 【ZOJ 2562】 More Divisors
- zoj2562--More Divisors(反素数模板)
- 浅谈移动测试
- static代码块,代码块 ,构造方法(一个参数),构造方法(二个参数)
- iOS UIPanGestureRecognizer(拖动手势) 和 点击按钮 实现类似左抽屉的效果
- Android第三方开源NiftyNotification(Android Toast替代品):动画效果生动有趣的通知
- hibernate入门
- ZOJ More Divisors 2562 (反素数)
- Notepad++ 快捷键 大全
- scons 编译
- 机器学习常用数学公式
- 关于移动端css用rem单位的情况
- hdoj StrangeStandard 4133 (反素数)
- 点滴 PUSH-PULL AND OPEN DRAIN+PULL-UP/DOWN
- 微信sharesdk
- 南大软院大神养成计划第十八天