博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论
阅读量:4457 次
发布时间:2019-06-08

本文共 1242 字,大约阅读时间需要 4 分钟。

 

首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数。

然后就可以搜了

#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;#define pb(x) push_back(x)#define ll long long#define mk(x, y) make_pair(x, y)#define lson l, m, rt<<1#define mem(a) memset(a, 0, sizeof(a))#define rson m+1, r, rt<<1|1#define mem1(a) memset(a, -1, sizeof(a))#define mem2(a) memset(a, 0x3f, sizeof(a))#define rep(i, n, a) for(int i = a; i
pll;const double PI = acos(-1.0);const double eps = 1e-8;const int mod = 1e9+7;const int inf = 1061109567;const int dir[][2] = { {-1, 0}, { 1, 0}, { 0, -1}, { 0, 1} };int n, f[105], prime[20], cnt;ll ans = 1e18+2;void dfs(int pos, int num, ll val) { if(pos>16) return ; if(num>n) return ; if(num == n) { ans = min(ans, val); return ; } for(int i = 1; i<=60; i++) { val *= prime[pos]; if(val>ans) break; dfs(pos+1, num*(i+1), val); }}int main(){ cin>>n; for(int i = 2; i<100; i++) { if(!f[i]) { for(int j = i+i; j<100; j+=i) { f[j] = 1; } prime[cnt++] = i; } } dfs(0, 1, 1); cout<
<

 

转载于:https://www.cnblogs.com/yohaha/p/5269209.html

你可能感兴趣的文章
使用ZIM桌面维基做笔记
查看>>
10-24
查看>>
javaweb(八)——HttpServletResponse对象(二)
查看>>
DbSchema注册码生成
查看>>
原根、与原根的应用(更新中)
查看>>
代理模式之静态代理
查看>>
微软MSN为吸引年轻人推出趋势追踪服务msnNOW
查看>>
Oracle数据处理
查看>>
SQL Server 2005中的类型与C#中的类型对应关系
查看>>
EntityConnection.ConnectionString 属性
查看>>
SimpleThreadPool
查看>>
快速理解聚合根、实体、值对象的区别和联系
查看>>
PAT——1030. 完美数列
查看>>
SPOJ简介。
查看>>
HGOI 20181028 题解
查看>>
python with as的用法
查看>>
Spring MVC 整合Activiti5.22配置详解
查看>>
『Python基础-14』匿名函数 `lambda`
查看>>
java: Set类及子类:TreeSet有序子类,HashSet无序子类:重复元素
查看>>
jquery: 一些常见的获取
查看>>