0
点赞
收藏
分享

微信扫一扫

CodeForces - 27E Number With The Given Amount Of Divisors (反素数入门)

yellowone 2023-04-20 阅读 52


CodeForces - 27E

Number With The Given Amount Of Divisors


Submit Status


Description



Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.


Input



The first line of the input contains integer n (1 ≤ n ≤ 1000).


Output



Output the smallest positive integer with exactly n


Sample Input



Input



4



Output



6



Input



6



Output



12




#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
typedef unsigned long long ll;
const ll INF = (ll)1<<63;
int n;
ll ans;
int p[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
void dfs(int gen,ll tmp,int num)
{
	if(num>n)
		return ;
	if(num==n&&ans>tmp)
		ans=tmp;
	for(int i=1;i<=63;i++)
	{
		if(ans/p[gen]<tmp)
			break;
		dfs(gen+1,tmp*=p[gen],num*(i+1));
	}
}
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		ans=INF;
		dfs(0,1,1);
		printf("%lld\n",ans);
	}
	return 0;
}



举报

相关推荐

0 条评论