bzoj千题计划296:bzoj1053: [HAOI2007]反素数ant
http://www.lydsy.com/JudgeOnline/problem.php?id=1053
求n以内约数个数最多的数
#include<cstdio> using namespace std; int n; int ans; long long tot; int prime[11]={0,2,3,5,7,11,13,17,19,23,29}; void dfs(int now,long long sum,long long num) { if(now==11) return; if(sum>tot || sum==tot && num<ans) { ans=num; tot=sum; } int cnt=0; while(num<=n) { dfs(now+1,sum*(cnt+1),num); num*=prime[now]; cnt++; } } int main() { scanf("%d",&n); dfs(1,1,1); printf("%d",ans); return 0; }