传送门

Description

给定一个正整数\(n\),输出最小的整数,满足这个整数有n个因子

Input

一行一个整数\(n\)

Output

一行一个整数,代表答案。

Hint

\(1~\leq~n~\leq~1000\)。保证答案不超过\(10^{18}\)

Solution

经典题。

引理:

对于一个唯一分解式形如\(x=p_1^{c_1}p_2^{c_2}p_3^{c^3}\cdots p_k^{c_k}\)的数字\(x\),则其因数个数为\(\prod(c_i+1)\)。

证明:

考虑乘法原理,第\(i\)项的指数有\(0~\sim~c_i\)共\(c_i+1\)种方式,根据唯一分解定理的逆定理,每一项指数不同所得到的数是不同的。于是根据乘法原理,其因数个数为\(\prod(c_i+1)\)。

证毕。

定理:

考虑一个因数个数为\(n\)的最小整数\(x\),则它的唯一分解式\(x=p_1^{c_1}p_2^{c_2}p_3^{c^3}\cdots p_k^{c_k}\)中,不妨设\(p_1~<~p_2~<~p_3~<~\cdots~<~p_k\),则一定满足:\(p_1=2\),且\(\forall ~i~>~1\),\(p_i\)是大于\(p_{i-1}\)的第一个质数,同时\(\forall~i~\in~[1,k)\),\(c_i~\leq~c_{i+1}\)。

证明:

1、若\(p\)在质数表上不是连续的,不妨设\(p_i~<~q~<p_{i+1}\),则将\(p_{i+1}\)替换为\(q\),\(x\)会变小,因为\(c_{i+1}\)不变,根据引理,因数个数不变。于是替换为\(q\)答案更优,这与\(x\)是最小的有\(n\)个因子的数矛盾。

2、若\(c_i\)不是单调不升,不妨设\(c_i~<~c_{i+1}\),则将两指数交换,\(x\)会变小。同上可证因数个数不变。于是交换后答案更优,这与\(x\)是最小的有\(n\)个因子的数矛盾。

证毕。

于是发现答案的唯一分界式,\(2\)一定会出现且指数最大。考虑\(2^{64}\)已经大于\(10^{18}\),所以指数最多为\(64\)。又发现前15个质数连乘的答案已经大于\(10^{18}\),所以质数最多是15个。于是爆搜一下,分别进行一下可行性剪枝和最优性剪枝,即可通过本题。

Code

#include<cstdio>
#define rg register
#define ci const int
#define cl const long long typedef long long int ll; template <typename T>
inline void qr(T &x) {
rg char ch=getchar(),lst=' ';
while((ch > '9') || (ch < '0')) lst=ch,ch=getchar();
while((ch >= '0') && (ch <= '9')) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
if(lst == '-') x=-x;
} namespace IO {
char buf[120];
} template <typename T>
inline void qw(T x,const char aft,const bool pt) {
if(x < 0) {x=-x,putchar('-');}
rg int top=0;
do {IO::buf[++top]=x%10+'0';} while(x/=10);
while(top) putchar(IO::buf[top--]);
if(pt) putchar(aft);
} template <typename T>
inline T mmax(const T a,const T b) {return a > b ? a : b;}
template <typename T>
inline T mmin(const T a,const T b) {return a < b ? a : b;}
template <typename T>
inline T mabs(const T a) {return a < 0 ? -a : a;} template <typename T>
inline void mswap(T &_a,T &_b) {
T _temp=_a;_a=_b;_b=_temp;
} const int prime[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; int n;
ll ans=1000000000000000001; void dfs(ll,int,int,int); int main() {
qr(n);
dfs(1ll,0,64,1);
qw(ans,'\n',true);
return 0;
} void dfs(ll now,int cur,int p,int cnt) {
if(cnt > n) return;
if(now <= 0ll) return;
if(now > ans) return;
if(cur > 15) return;
if(cnt == n) {ans=now;return;}
for(int i=1;i<=p;++i) {
dfs(now*=prime[cur],cur+1,i,cnt*(i+1));
}
}

Summary

对于一个唯一分解式形如\(x=p_1^{c_1}p_2^{c_2}p_3^{c^3}\cdots p_k^{c_k}\)的数字\(x\),则其因数个数为\(\prod(c_i+1)\)。

【数学】【CF27E】 Number With The Given Amount Of Divisors的更多相关文章

  1. 数论 CF27E Number With The Given Amount Of Divisors

    求因子数一定的最小数(反素数) #include<iostream> #include<string> #include<cmath> #include<cs ...

  2. codeforces 27E Number With The Given Amount Of Divisors

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

  3. Codeforces Beta Round #27 (Codeforces format, Div. 2) E. Number With The Given Amount Of Divisors 反素数

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

  4. E. Number With The Given Amount Of Divisors

    E. Number With The Given Amount Of Divisors time limit per test 2 seconds memory limit per test 256 ...

  5. Codeforces 27E. Number With The Given Amount Of Divisors (暴力)

    题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...

  6. codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论

    题目链接 首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数. 然后就可以搜了 #include <iostrea ...

  7. Codeforces Beta Round #27 E. Number With The Given Amount Of Divisors 含n个约数最小数

    http://codeforces.com/problemset/problem/27/E RT,求含n个约数的最小的数 我们设答案p = 2^t1 * 3^t2 * -- * p^tk(其中p是第k ...

  8. 大家一起做训练 第一场 E Number With The Given Amount Of Divisors

    题目来源:CodeForce #27 E 题目意思和题目标题一样,给一个n,求约数的个数恰好为n个的最小的数.保证答案在1018内. Orz,这题训练的时候没写出来. 这道题目分析一下,1018的不大 ...

  9. codeforces 27 E. Number With The Given Amount Of Divisors(数论+dfs)

    题目链接:http://codeforces.com/contest/27/problem/E 题意:问因数为n个的最小的数是多少. 题解:一般来说问到因数差不多都会想到素因子. 任意一个数x=(p1 ...

随机推荐

  1. centos 7 安装和基本配置

    U盘安装centos 7 还是官方文档最准确. 下载centos https://docs.centos.org/en-US/centos/install-guide/downloading/ 制作安 ...

  2. Python解包参数列表及 Lambda 表达式

    解包参数列表 当参数已经在python列表或元组中但需要为需要单独位置参数的函数调用解包时,会发生相反的情况.例如,内置的 range() 函数需要单独的 start 和 stop 参数.如果它们不能 ...

  3. Codeforces 552 E. Two Teams

    E. Two Teams time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  4. [ Continuously Update ] This is an *Index Page*.

    The links below present papers in certain fields. Despite overlaps exist, their emphasis is markedly ...

  5. JavaScript 之 ajax

    1. AJAX 的概念 AJAX,即 Asynchronous JavaScript and XML(异步的 JavaScript 和 XML) 同步:前面的代码不执行完毕,后面的代码无法执行 异步: ...

  6. git blame 查看某行代码提交记录

    1. 在当前git项目目录下执行 git blame -L 38,38 <filename> 例子:  git blame -L 38,38 src/component/BarCode/i ...

  7. MD5加密字符串--基于python

    import hashlib#md5加密32位def md5(str): import hashlib m = hashlib.md5() m.update(str) return m.hexdige ...

  8. 软工1816 · Alpha冲刺(5/10)

    团队信息 队名:爸爸饿了 组长博客:here 作业博客:here 组员情况 组员1(组长):王彬 过去两天完成了哪些任务 后端代码复审 福大各个食堂的菜品口味量化.属性标记 组织前后端线下协作 接下来 ...

  9. 模拟登入教务处(header)

    import HTMLParser import urlparse import urllib import urllib2 import cookielib import string import ...

  10. 第四周作业——C语言自评

    1.你对自己的未来有什么规划?做了哪些准备?以目前的现状来说,希望至少能够掌握专业所要求的基本操作,然后一步步去深入.提升,毕业之后不会灰溜溜的一次次求职失败.目前更多的是利用闲暇时间补回过去老师同学 ...