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

#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 ;
}

数论 CF27E Number With The Given Amount Of Divisors的更多相关文章

  1. codeforces 27E 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 ...

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

  4. codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论

    题目链接 首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数. 然后就可以搜了 #include <iostrea ...

  5. 【数学】【CF27E】 Number With The Given Amount Of Divisors

    传送门 Description 给定一个正整数\(n\),输出最小的整数,满足这个整数有n个因子 Input 一行一个整数\(n\) Output 一行一个整数,代表答案. Hint \(1~\leq ...

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

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

  7. Codeforces 27E. Number With The Given Amount Of Divisors (暴力)

    题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...

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

  9. 大家一起做训练 第一场 E Number With The Given Amount Of Divisors

    题目来源:CodeForce #27 E 题目意思和题目标题一样,给一个n,求约数的个数恰好为n个的最小的数.保证答案在1018内. Orz,这题训练的时候没写出来. 这道题目分析一下,1018的不大 ...

随机推荐

  1. LeetCode刷题笔记和想法(C++)

    主要用于记录在LeetCode刷题的过程中学习到的一些思想和自己的想法,希望通过leetcode提升自己的编程素养 :p 高效leetcode刷题小诀窍(这只是目前对我自己而言的小方法,之后会根据自己 ...

  2. Python 矩阵相关

    Python 中矩阵运算主要使用numpy库.NumPy的主要对象是同种元素的多维数组.这是一个所有的元素都是一种类型.通过一个正整数索引的元素表格(通常是元素是数字).因此对于随机查找来说,比pyt ...

  3. Lesson 7 Bats

    In what way does echo-location in bats play a utilitarian role? Not all sounds made by animals serve ...

  4. Lesson 46 Hobbies

    Who, according to the authour, are 'Fortune's favoured children'? A gifted American psychologist has ...

  5. Vivado ILA观察信号和调试过程

    先简单介绍一下ILA(Integrated Logic Analyzer)生成方法.这里有两种办法完成Debug Core的配置和实现. 方法一.mark_debug综合选项+Set Up Debug ...

  6. JavaScript 标识符,关键字和保留字

    JavaScript 标识符,关键字和保留字 标识符 标识符(Identifier)就是名称的专业术语.JavaScript 标识符包括变量名.函数名.参数名和属性名. 合法的标识符应该注意以下强制规 ...

  7. bsearch的使用

    懒得写二分查找,结果发现stdlib里自带了二分查找. C 库函数 void *bsearch(const void *key, const void *base, size_t nitems, si ...

  8. 解决NLPIR汉语分词系统init failed问题

    今天第一次使用NLPIR汉语分词系统. 遇到的问题: 当点击时, 出现以下界面 看了博客https://blog.csdn.net/yuyanyanyanyanyu/article/details/5 ...

  9. 第1节 IMPALA:10、基本查询语法;11、数据加载的4种方式

    9.3. 创建数据库表 创建student表 CREATE TABLE IF NOT EXISTS mydb1.student (name STRING, age INT, contact INT ) ...

  10. BSGS&ExBSGS

    BSGS&ExBSGS 求解形如 \[a^x\equiv b\pmod p\] 的高次同余方程 BSGS 假装\(gcd(a,p)=1\). 设\(m=\lceil\sqrt p \rceil ...