# 【枚举+小技巧】【TOJ4115】【Find the number】

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include<algorithm>
#include <sstream>
#include <string>
#define oo 0x13131313
using namespace std;
int n;
int ok;
int q[30]={0,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};
int A[30];
int B[30];
int ans[30];
int anscishu=0;
double MAX=1<<30;
const long long mod=1000000007;
void dfs(int nn,int k,int now,int cishu)
{
if(k==1)
{
if(nn==1) return ;
A[1]=nn;
double t=0;
for(int i=1;i<=cishu;i++)
B[i]=A[i];
sort(B+1,B+cishu+1);
for(int i=1;i<=cishu;i++)
{
t=t+(double)(B[i]-1)*(double)log(q[cishu-i+1]);
}
if(t<MAX)
{
MAX=t;
anscishu=cishu;
for(int i=1;i<=cishu;i++)
{
ans[i]=B[i];
}
}
ok=1;
return ;
}
for(int i=now;i<=nn;i++)
{
if(nn%i==0)
{
A[k]=i;
dfs(nn/i,k-1,i,cishu);
}
}
}
void solve()
{
MAX=1<<31-1;
for(int i=1;i<=17;i++)
{
ok=0;
dfs(n,i,2,i);
if(ok==0) break;
}
}
void print()
{
long long Ans=1;
for(int i=1;i<=anscishu;i++)
{
for(int j=1;j<=ans[i]-1;j++)
{
Ans=(Ans*(long long)q[anscishu-i+1])%mod;
}
}
printf("%lld\n",Ans);
}
int main()
{
// freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
while(cin>>n)
{
solve();
print();
}
}


#### PCIe实践之路：设备枚举

2017-07-08 22:46:17

#### Linux kernel中USB枚举失败总结

2015-03-21 22:32:54

#### typescript中的enum和类型转换

2018-01-02 09:18:14

#### ［Leetcode］287. Find the Duplicate Number简单解法及解释 双指针复杂度O(n)

2016-01-01 11:34:20

#### lintcode Find the Missing Number II

2017-03-07 22:29:31

#### [LintCode]Find the Missing Number II

2017-03-27 09:46:23

#### leetcode -- Find the Duplicate Number-- 经典重点

2015-12-23 17:50:39

#### 01 Find the odd int(找到出现次数为奇数的int)

2016-11-18 15:59:56

#### 让OpenCV枚举所有摄像头-附如何建立Windows下的OpenCV工程

2015-12-29 20:52:01

#### HDU5778之暴力枚举

2016-07-31 01:37:33