Description
给出一整数n,求有
Input
一个正整数n(1≤n≤1000)
Output
输出有n个因子的最小正整数
Sample Input
4
Sample Output
6
Solution
答案不超过
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int INF=0x3f3f3f3f,maxn=101;
int n,p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll ans;
void dfs(int pos,int tn,ll tans)
{
if(n==tn)
{
ans=min(ans,tans);
return ;
}
for(int i=1;i<=60;i++)
{
if(tn*(i+1)>n||tans*p[pos]>ans)break;
tans*=p[pos];
dfs(pos+1,tn*(i+1),tans);
}
}
int main()
{
while(~scanf("%d",&n))
{
ans=1e18;
dfs(0,1,1);
printf("%I64d\n",ans);
}
return 0;
}

本文介绍了一种算法,用于寻找具有指定数量因子的最小正整数,并提供了一个具体的C++实现示例,该算法通过限制搜索范围来提高效率。
396

被折叠的 条评论
为什么被折叠?



