【bzoj1053】[HAOI2007]反素数ant DFS

Description

对于任何正整数x,其约数的个数记作g(x)。例如g(1)=1、g(6)=4。
如果某个正整数x满足:g(x)>g(i) 0

Input

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

Output

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

Sample Input

1000

Sample Output

840

HINT

Source


求一个小于n的数x,使 d(x) 大于所有的 d(i)(0<i<x)

(打表的程序到现在还没跑完…)

这题选小素数肯定比选大素数优,所以枚举小素数选几个暴力即可…

(hzwer说12个素数就可以了…求证明QAQ)

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long LL;

const int SZ = 10000010;

bool vis[SZ];

int pri[] = {0,2,3,5,7,11,13,17,19,23,29,31,37};

int n;

int ans,maxd = 0;

int t[SZ];

void dfs(LL now,int d,int pos)
{
    if(d > maxd || (d == maxd && now < ans)) ans = now,maxd = d;

    if(pos == 13)   return;
    LL a = 1;
    for(int i = 0;;i ++)
    {
        if(a * now > n) break;
        dfs(now * a,d * (i + 1),pos + 1);
        a *= pri[pos];
    }
}


int main()
{
    scanf("%d",&n);
    dfs(1,1,1);
    printf("%d",ans);
    return 0;
}

/*

1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,7560,10080,15120,20160,25200,27720,45360,50400,55440,83160,110880,166320,221760,277200,332640,498960,554400,665280,720720,1081080,1441440,2162160,2882880,3603600,4324320,6486480,7207200,8648640,

2000000000


*/
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值