码迷,mamicode.com
首页 > 其他好文 > 详细

[POI2002][HAOI2007]反素数 数论 搜索 好题

时间:2018-11-01 18:57:54      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:lse   ==   long   clu   std   lld   type   names   turn   

Code:

#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int prime[]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,51,53};
ll n, maxn;
int cur;
void dfs(int dep,ll m,int t,int p){  //上一个指数
	if(dep==12){
		if(t>=cur){
			if(t>cur) maxn=m, cur=t; 
			else if(m<maxn) maxn=m;
		}
		return;
	}
	ll cnt=1;
	for(int i=0;i<=p;++i){
		dfs(dep+1,m*cnt,t*(i+1),i);
		cnt*=prime[dep];
		if(m*cnt>n) break;
	}
}
int main(){
	//freopen("input.in","r",stdin);
	scanf("%lld",&n);
	dfs(1,1,1,30);
	printf("%lld",maxn);
	return 0;
}

  

[POI2002][HAOI2007]反素数 数论 搜索 好题

标签:lse   ==   long   clu   std   lld   type   names   turn   

原文地址:https://www.cnblogs.com/guangheli/p/9891053.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!