2021-08-11 SSL 模拟赛 T4
啦啦啦,仍然依旧还是继续没有标题
这道题其实是一道原题,
原题链接:【ybtoj】/【洛谷】
然后因为我已经写过一篇题解了,所以这里就不讲思路了,直接上代码。
原来的题解
代码:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#define r register
#define rep(i,x,y) for(r ll i=x;i<=y;++i)
#define per(i,x,y) for(r ll i=x;i>=y;--i)
using namespace std;
typedef long long ll;
ll p[]={0,2,3,5,7,11,13,17,19,23,29,31},a[50];
ll top,n,maxn,maxt;
void dfs(ll now,ll val,ll tot)
//now 现在取到第几个质数,val 现在数的值,tot 现在的约数个数
{
if(val>n) return ;
if(now>11) return ;
if((tot>maxt)||(tot==maxt&&val<maxn))
{
maxn=val;
maxt=tot;
}
rep(i,0,a[now-1])
{
a[now]=i;//记录次数
dfs(now+1,val,tot*(i+1));
val*=p[now];
if(val>n) return ;
}
}
int main()
{
scanf("%lld",&n);
a[0]=32; //初始可以最多取32个
dfs(1,1,1);
cout<<maxn;
return 0;
}