您的位置:首页 > 其它

BZOJ1053 [HAOI2007] 反素数ant

2016-01-21 21:59 465 查看
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1053

Description

对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。
如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数。例如,整数1,2,4,6等都是反质数。
现在给定一个数N,你能求出不超过N的最大的反质数么?

Input

一个数N(1<=N<=2,000,000,000)。

Output

不超过N的最大的反质数。

看这个吧:这是一个百度文库链接

#include <cstdio>
#define rep(i,l,r) for(int i=l; i<=r; i++)
using namespace std;
typedef long long ll;
const int p[] = {2,3,5,7,11,13,17,19,23,29};
ll n;
int ans,num;
void dfs(int x,ll now,int cnt,int last){ // 第几个质数,从开始搜索至今质数的乘积,质数个数,质数幂的次数
if (x == 9){
if (now > ans && cnt > num) ans = now, num = cnt;
if (now <= ans && cnt >= num) ans = now, num = cnt;
return;
}
int t = 1;
rep(i,0,last){
dfs(x+1,now*t,cnt*(i+1),i);
t *= p[x];
if (now * t > n) break;
}
}
int main(){
scanf("%lld",&n);
dfs(0,1,1,10);
printf("%d\n",ans);
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: