#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<cmath>
#include<cassert>
#include<cstring>
#include<iomanip>
using namespace std;
typedef long long i64;
#define out64 "%lld\n"
#define in64 "%lld"
/************ for topcoder by zz1215 *******************/
#define FOR(i,a,b) for( int i = (a) ; i <= (b) ; i ++)
#define FFF(i,a) for( int i = 0 ; i < (a) ; i ++)
#define FFD(i,a,b) for( int i = (a) ; i >= (b) ; i --)
#define S64(a) scanf(in64,&a)
#define SS(a) scanf("%d",&a)
#define LL(a) ((a)<<1)
#define RR(a) (((a)<<1)+1)
#define pb push_back
#define CL(Q) while(!Q.empty())Q.pop()
#define MM(name,what) memset(name,what,sizeof(name))
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
const int inf = 0x3f3f3f3f;
const i64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double oo = 10e9;
const double eps = 10e-9;
const double pi = acos(-1.0);
const i64 maxn = 10000000000000000LL;
struct zz
{
i64 x;
i64 n;
bool operator < (const zz & cmp ) const
{
return x < cmp.x;
}
}zx;
vector<i64>p;
vector<zz>vx;
vector<i64>v;
bool isp(i64 x)
{
i64 temp = sqrt(x);
for(int i=0;i<p.size();i++)
{
if(p[i]>temp) return true;
if(!(x%p[i])) return false;
}
return true;
}
void init()
{
p.clear();
p.pb(2);
for(int i=3;i<100;i++)
{
if(isp(i))
{
p.pb(i);
}
}
return ;
}
void dfs(i64 rest,i64 id=0,i64 pre=inf,i64 x=1,i64 n=1)
{
if(id>16) return ;
if(rest == 0)
{
zx.x = x;
zx.n = n;
vx.pb(zx);
return ;
}
i64 temp;
bool ok;
for(int i=min(pre,rest);i>=1;i--)
{
temp = x;
ok = true;
for(int u=1;u<=i;u++)
{
temp *= p[id];
if(temp > maxn)
{
ok = false;
break;
}
}
if(!ok) continue;
dfs(rest-i,id+1,i,temp,n*(i+1));
}
return ;
}
void start()
{
for(int i=0;i<30;i++)
{
dfs(i);
}
sort(vx.begin(),vx.end());
i64 temp = 0;
v.clear();
for(int i=0;i<vx.size();i++)
{
if(vx[i].n <= temp)
{
continue;
}
else
{
temp = vx[i].n;
v.pb(vx[i].x);
}
}
v.pb(inf64);
return ;
}
i64 n;
i64 find()
{
int l = 0;
int r = v.size()-1;
int mid;
while(l<r)
{
mid = (l+r+1)/2;
if(v[mid] < n)
{
l = mid;
}
else if(v[mid]>n)
{
r = mid-1;
}
else
{
return v[mid];
}
}
return v[l];
}
int main()
{
init();
start();
while(cin>>n)
{
cout<<find()<<endl;
}
return 0;
}
zoj2562 More Divisors
最新推荐文章于 2019-03-10 15:38:45 发布