题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1053
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <cassert>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define clr(a,x) memset(a,(x),sizeof(a))
#define eps 1e-8
#define LL long long
#define mp make_pair
const int maxn=100000+5;
int pe[]={2,3,5,7,11,13,17,19,23,29};
int N,sz;
pair<LL,LL> ant[10000];
void dfs(int cur,LL v,int limit,LL num)
{
if(v>N) return;
ant[sz++]=mp(v,num);
if(cur==10) return;
rep(i,0,limit) {
if(v*pe[cur]>N) break;
dfs(cur+1,v*=pe[cur],i+1,num*(i+2));
}
}
int main()
{
//LL v=1;
// rep(i,0,10) v*=pe[i];
// cout<<v<<endl;
while(scanf("%d",&N)==1) {
sz=0; dfs(0,1,1000,1);
int ans=0,maxnum=0;
sort(ant,ant+sz);
rep(i,0,sz) {
if(ant[i].second>maxnum) ans=ant[i].first,maxnum=ant[i].second;
}
cout<<ans<<endl;
}
}