数论 CF27E Number With The Given Amount Of Divisors
2024-10-08 16:53:53
求因子数一定的最小数(反素数)
#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 ;
}
最新文章
- 家有学霸的CEO
- 【字符串排序】n个数连接得到最小或最大的多位整数
- Html - a标签如何包裹Div
- JBoss错误
- MySQL DATE_ADD() 函数
- HDU5438--Ponds (拓排+BFS)
- HTML,XML中的转义字符
- bzojj1764: [Baltic2009]monument
- ubuntu 12 64 桌面版Oracle11g 安装
- 通过JSTL用表格的形式显示
- PHP 7 探针的安装与测试
- Windows DDB和DIB技术应用(3)--图元外边矩形检测
- 安卓中onBackPressed ()方法的使用
- 解析DBR操作系统引导记录数据
- 【NOIP2006提高组】能量项链
- vim批量注释
- OAuth2.0的原理介绍
- 【Ubuntu】xrdp完美实现Windows远程访问Ubuntu 16.04
- Python验证码识别处理实例 深度学习大作业
- EL表达式无法获取Spring MVC的Model封装好的数据解决方法