当前位置 : 主页 > 网络编程 > net编程 >

【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)

来源:互联网 收集:自由互联 发布时间:2023-09-07
题干: 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 exceed1018. Input The first line of the input contains integer n (1 ≤  n  ≤ 

题干:

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 divisors.

Examples

Input

4

Output

6

Input

6

Output

12

题目大意:

给定一个正整数n,求一个最小的正整数,使得它的因子个数恰为n。保证答案不超过1018

解题报告:

   这题用到了一个概念叫反素数、、学习了一波。,但是其实就算没有这个概念,做法也很显然吧,,做个唯一分解这题就做完了。知识点在下面附上了。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
ll biao[55] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll minn = 1e18+5;
ll n;
void dfs(ll dep,ll tmp,ll cur) {
if(cur > n) return ;
if(cur==n) minn = min(tmp,minn);
for(ll i = 1; i<=63; i++) {
if(minn < tmp * biao[dep]) break;
tmp = tmp * biao[dep];
dfs(dep+1,tmp,cur*(i+1));
}
}
int main()
{
int t;
cin>>n;
dfs(0,1,1);
printf("%lld\n",minn);
return 0 ;
}

 

 

知识点:反素数:来源链接

今天要我要讲的是反素数,在ACM中也算是常见的考点,那么对于搞ACM的同学来说,很有必要搞清楚它,所以接下

来我会很详细地讲解。

 

在讲解反素数之前,我们先来看反素数的概念。

 

反素数的定义:对于任何正整数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include,其约数个数记为【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_约数个数_02,例如【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_03,如果某个正整数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include满足:对任意的正整

            数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_05,都有【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include_06,那么称【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include为反素数。

从反素数的定义中可以看出两个性质:

(1)一个反素数的所有质因子必然是从2开始的连续若干个质数,因为反素数是保证约数个数为【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_08的这个数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include尽量小

(2)同样的道理,如果【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_10,那么必有【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include_11

在ACM竞赛中,最常见的问题如下:

(1)给定一个数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include,求一个最小的正整数【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_08,使得【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_08的约数个数为【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include

(2)求出【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_16中约数个数最多的这个数

从上面的性质中可以看出,我们要求最小的【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_08,它的约数个数为【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#include,那么可以利用搜索来解。

以前我们求一个数的所有因子也是用搜索,比如【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_#define_19,以每一个【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_约数个数_20为树的一层建立搜索树,深度为【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_约数个数_21

【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_约数个数_22为例进行说明,建树如下:

 

【CodeForces - 27E】Number With The Given Amount Of Divisors (数论,数学,反素数)_约数个数_23

可以看出从根节点到每一个叶子结点这条路径上的所有数字乘起来都是12的约数,所以12有6个约数。


【感谢龙石数据为本站数据中台建设方案 http://www.longshidata.com/pages/government.html,感恩 】
上一篇:【PAT - 甲级1012】The Best Rank (25分)
下一篇:没有了
网友评论