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大的质数),则必有: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个约数最小数的更多相关文章
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- 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 ...
- codeforces 27 E. Number With The Given Amount Of Divisors(数论+dfs)
题目链接:http://codeforces.com/contest/27/problem/E 题意:问因数为n个的最小的数是多少. 题解:一般来说问到因数差不多都会想到素因子. 任意一个数x=(p1 ...
- Codeforces Beta Round #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- Codeforces Beta Round 84 (Div. 2 Only)
layout: post title: Codeforces Beta Round 84 (Div. 2 Only) author: "luowentaoaa" catalog: ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- 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]中有多少个数 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
随机推荐
- NOI导刊 2018河南郑州游记
前言 本蒟蒻来自浙江的弱市弱校,因为不想两年\(OI\)一场空,以及想出去玩,所以与同届大佬一起报了\(NOI\)导刊,希望能留下点不错的记忆吧. \(Day\ 0\) \(10\)月\(1\)日 经 ...
- Vsphere初试——架设Panabit行为管理
Panabit是目前国内X86平台单板处理能力最高(双向40G).提供免费版本(软件形态),是以DPI为核心优势并发展起来的最专业.上线效果最好.性价比最高的新一代应用网关.Panabit流控引擎,基 ...
- 关于C的int
在c运行库头文件<stdint.h>中typedef各种类型的int typedef signed char int8_t; typedef unsigned char uint8_t; ...
- Eclipse新建tld文件
tld(tag lib description文件)就是以.tld结尾的XML文件 选好目录右键 --> New --> Other -->找到XML FIle --> Nex ...
- 开发apicloud模块遇到的几个梗
2017-06-04 原来模块中不能的R.id.xxx,只能用UZResourcesIDFinder.getResIdID("mo_minivr_framecontainer") ...
- 学习python 多进程和多线程
''' 学习多进程和多线程 ''' import multiprocessing def deadLoop(): while True: pass if __name__ == '__main__': ...
- socket的同步异步的性能差别,以及listen的参数backlog
先说listen的参数backlog,同步系统中分别设置为5,512,1024的跑分情况 跑分工具apache的ab,参数为:ab -n50000 -c300 backlog=5跑分结果 Reques ...
- java14
1.方法:定义一个小功能,储存某段代码,方便在需要时调出来反复使用 !!!!重复使用 格式: static void 名称(){ } 注意点: ①在static main方法中要调用其他方法,调用的其 ...
- Sencha extjs 的安装
delphi 的母公司Idera 突然就把sencha extjs 收购了,这确实是一个很好的消息,意味着delphi 开始在web方面开始发力, 目前delphi 集成extjs 的呼声越来越强烈, ...
- markdown中自己偶尔需要的小技巧
慢慢积累,需要时搜索,并记录与此. 1.写文章时,由于markdown不负责首行缩进,所以“空格”需要特殊的方法去实现,最简单方便的是--输入全角空格(切换全角输入,点空格) 2.markdown中注 ...