求因子数一定的最小数(反素数)

#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<sstream>
#include<cstdio>
#define INF 0x3f3f3f3f
const int maxn = 1e3 + ;
const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;
using namespace std; //若取前17个素数,其乘积大于要求范围
ull p[] = { ,,,,,,,,,,,,,, }; ull ans;
ull n; //depth 当前在枚举第几个素数,num:当前因子数
//tmp:当前因子数量为num的时候的数值
//up:上一个素数的幂,这次应该小于等于这个幂次 void dfs(ull depth, ull tmp, ull num, ull up) {
if (num > n || depth >= ) return;
if (num == n && ans >= tmp) {
ans = tmp;
return;
}
for (int i = ; i <= up; i++) {
if (tmp / p[depth] > ans) return;
dfs(depth + , tmp = tmp * p[depth], num * (i + ), i);
}
} int main() {
while (scanf("%llu", &n) != EOF) {
ans = INF;
dfs(, , , );
printf("%llu", ans);
}
return ;
}

最新文章

  1. 家有学霸的CEO
  2. 【字符串排序】n个数连接得到最小或最大的多位整数
  3. Html - a标签如何包裹Div
  4. JBoss错误
  5. MySQL DATE_ADD() 函数
  6. HDU5438--Ponds (拓排+BFS)
  7. HTML,XML中的转义字符
  8. bzojj1764: [Baltic2009]monument
  9. ubuntu 12 64 桌面版Oracle11g 安装
  10. 通过JSTL用表格的形式显示
  11. PHP 7 探针的安装与测试
  12. Windows DDB和DIB技术应用(3)--图元外边矩形检测
  13. 安卓中onBackPressed ()方法的使用
  14. 解析DBR操作系统引导记录数据
  15. 【NOIP2006提高组】能量项链
  16. vim批量注释
  17. OAuth2.0的原理介绍
  18. 【Ubuntu】xrdp完美实现Windows远程访问Ubuntu 16.04
  19. Python验证码识别处理实例 深度学习大作业
  20. EL表达式无法获取Spring MVC的Model封装好的数据解决方法

热门文章

  1. win10安装Oracle11g
  2. linux磁盘扩容常见问题
  3. 2017 青岛现场赛 Suffix
  4. Screen命令让Linux shell在后台运行
  5. prometheus 统计MySQL 自增主键的剩余可用百分比
  6. Linux centosVMware MySQL主从介绍、准备工作、配置主、配置从、测试主从同步
  7. formatTime() 时间戳,返回数据是计算距离现在的时间
  8. centos6忘记root密码
  9. JDBC和连接池
  10. 700k把web端程序包装为桌面程序