[BZOJ1053][HAOI2007]反素数ant

来源:互联网 发布:湖南工业大学网络课程 编辑:程序博客网 时间:2024/04/20 07:06

原题地址

反素数…

关于反素数的资料

AC code:

#include <cstdio>typedef long long ll;ll n,mx,ans;ll p[20]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};void DFS(ll x,ll last,ll tot,ll val){    if(tot>mx||tot>=mx&&val<=ans){        mx=tot;        ans=val;    }    for(ll i=last;i;i--){        ll t=val;        for(ll j=1;j<=i;j++){            t*=p[x];            if(t>n) break;        }        if(t>n) continue;        DFS(x+1,i,tot*(i+1),t);    }}int main(){    scanf("%lld",&n);    DFS(1,31,1,1);     printf("%lld\n",ans);    return 0;}
0 0