http://codeforces.com/problemset/problem/27/E

RT,求含n个约数的最小的数

我们设答案p = 2^t1 * 3^t2 * …… * p^tk(其中p是第k大的质数),则必有:t1 >= t2 >= t3 >= … >= tk >= 0。

反证法证明:若不然可将{ti}由大到小排序,设形成的新有序序列是{ti’},t1' >= t2' >= t3' >= … >= tk';令p’ = 2^t1' * 3^t2' * …… * p^tk',则:p' < p,但p'的约数个数却不少于p,矛盾。所以必有:t1 >= t2 >= t3 >= … >= tk。

然后就是dfs可搞,传递三个参数:构造的t序列长度,构造出的数的约数的个数,构造出的数的大小。

ULL可做

#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define clr0(x) memset(x,0,sizeof(x))
#define eps 1e-9
const double pi = acos(-1.0);
typedef long long LL;
typedef unsigned long long ULL;
const int modo = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 1005,maxm = 1e4 + 5;
int n,pr[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
ULL ans = ~0ULL;
void dfs(int dep,int cnt,ULL res)
{
if(cnt > n)
return;
if(cnt == n){
ans = min(ans,res);
return ;
}
for(int i = 1;i <= 63;++i){
if(res > ans/pr[dep])
break;
dfs(dep+1,cnt*(i+1),res *= pr[dep]);
}
}
int main(){
RD(n);
dfs(0,1,1);
printf("%I64d\n",ans);
return 0;
}

LL可做

#pragma comment(linker, "/STACK:36777216")
#pragma GCC optimize ("O2")
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define clr0(x) memset(x,0,sizeof(x))
#define eps 1e-9
const double pi = acos(-1.0);
typedef long long LL;
typedef unsigned long long ULL;
const int modo = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxn = 1005,maxm = 1e4 + 5;
int n,pr[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
LL ans = 1e18;
void dfs(int dep,int cnt,LL res)
{
if(cnt > n)
return;
if(cnt == n){
ans = min(ans,res);
return ;
}
for(int i = 1;i <= 63;++i){
if(res > ans/pr[dep])
break;
dfs(dep+1,cnt*(i+1),res *= pr[dep]);
}
}
int main(){
RD(n);
dfs(0,1,1);
printf("%I64d\n",ans);
return 0;
}

Codeforces Beta Round #27 E. Number With The Given Amount Of Divisors 含n个约数最小数的更多相关文章

  1. Codeforces Beta Round #27 (Codeforces format, Div. 2)

    Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...

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

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

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

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round 84 (Div. 2 Only)

    layout: post title: Codeforces Beta Round 84 (Div. 2 Only) author: "luowentaoaa" catalog: ...

  6. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  7. Codeforces Beta Round #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  8. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  9. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

随机推荐

  1. BZOJ3191或洛谷2059 [JLOI2013]卡牌游戏

    BZOJ原题链接 洛谷原题链接 我们可以倒着来\(DP\). 设\(f[i][j]\)表示剩余\(i\)个人,从庄家数起第\(j\)个人的胜率,设当前枚举到第\(k\)张牌,该情况下这一轮淘汰的位置为 ...

  2. 循环&信息添加&颜色修改

            #import "AViewController.h" @interface AViewController () <UIActionSheetDelegat ...

  3. Luogu1070-道路游戏-动态规划

    Solution 用对角线的前缀和快速进行转移,复杂度$O(N^3)$, 洛谷神机太快了$N^3$都能过 然而正解是单调队列优化, 能优化到$O(N^2)$,然而我弱得什么都不会 Code #incl ...

  4. Linux网络端口命名规则,一致性网络设备命名

    参考文档: https://www.cnblogs.com/pipci/p/9229571.html 一致性网络设备命名,即Consistent Network Device Naming. 一.服务 ...

  5. MySQL 系列(一)安装

    MySQL 系列(一)安装 以 Centos7 下安装 MySQL 5.6 为例. 一.环境准备 (1) 下载 下载地址: https://dev.mysql.com/get/Downloads/My ...

  6. 设计师别浪费时间啦,快来试试这款Sketch标注插件吧

    随着移动互联网的快速发展,用户的需求也在不断地增大,这对产品经理还有设计师的考验是越来越大.市场环境的变化让我们深信为快不破,但是一个产品的产出需要各个环节的紧密配合,但往往在产品输出过程中,由于分工 ...

  7. MS SQMServer2008R2 连接不到远程服务的解决办法

    问题: MS SQMServer2008R2 连接不到远程服务的解决办法.程序提示的错误如下: [2017/02/19 17:46:21] 在与 SQL Server 建立连接时出现与网络相关的或特定 ...

  8. jvm 基础

    1. JDK 包含 java 程序设计语言,JVM, Java API类库. java 开发最小环境 2. JRE : Java API类库中java se API 子集和java 虚拟机(HotSp ...

  9. fastcgi 环境变量例子

    例如请求的url http://172.28.250.184:8099/aa.php?var=ccccc&value=bbbbbb 前两个字节分别代表  变量名长度  和 变量值长度. 0x0 ...

  10. openssl AES加密

    此代码不涉及ECB和CBC等关联加密 #include <stdio.h> #include <string.h> #include <stdlib.h> #inc ...