Problem - 27E - Codeforces
题意:
思路:
爆搜分解质因子的模板题,记录一下板子
Code:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mxn=1e6+10;
const int mxe=1e6+10;
const int mxv=1e6+10;
const int mod=1e9+7;
const int Inf=1e18;
int N,len=0;
int ans=1e18;
int vis[mxn];
int prime[mxn];
void P_init(int n){
for(int i=2;i<=n;i++){
if(!vis[i]) prime[++len]=i;
for(int j=1;i<=n/prime[j];j++){
vis[i*prime[j]]=1;
if(i%prime[j]==0) break;
}
}
}
void dfs(int now,int k,int last,int cnt){
if(cnt>N) return;
if(now<=0ll) return;
if(now>ans) return;
if(k>16) return;
if(cnt==N){
ans=now;
return;
}
for(int i=1;i<=last;i++){
dfs(now*=prime[k],k+1,i,cnt*(i+1));
}
}
void solve(){
cin>>N;
dfs(1ll,1,64,1);
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int __=1;//cin>>__;
P_init(1e6);
while(__--)solve();return 0;
}