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

  1. #include<iostream>
  2. #include<string>
  3. #include<cmath>
  4. #include<cstring>
  5. #include<vector>
  6. #include<map>
  7. #include<set>
  8. #include<algorithm>
  9. #include<queue>
  10. #include<stack>
  11. #include<list>
  12. #include<sstream>
  13. #include<cstdio>
  14. #define INF 0x3f3f3f3f
  15. const int maxn = 1e3 + ;
  16. const double PI = acos(-1.0);
  17. typedef long long ll;
  18. typedef unsigned long long ull;
  19. using namespace std;
  20.  
  21. //若取前17个素数,其乘积大于要求范围
  22. ull p[] = { ,,,,,,,,,,,,,, };
  23.  
  24. ull ans;
  25. ull n;
  26.  
  27. //depth 当前在枚举第几个素数,num:当前因子数
  28. //tmp:当前因子数量为num的时候的数值
  29. //up:上一个素数的幂,这次应该小于等于这个幂次
  30.  
  31. void dfs(ull depth, ull tmp, ull num, ull up) {
  32. if (num > n || depth >= ) return;
  33. if (num == n && ans >= tmp) {
  34. ans = tmp;
  35. return;
  36. }
  37. for (int i = ; i <= up; i++) {
  38. if (tmp / p[depth] > ans) return;
  39. dfs(depth + , tmp = tmp * p[depth], num * (i + ), i);
  40. }
  41. }
  42.  
  43. int main() {
  44. while (scanf("%llu", &n) != EOF) {
  45. ans = INF;
  46. dfs(, , , );
  47. printf("%llu", ans);
  48. }
  49. return ;
  50. }

数论 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. 解决国内GitHub加载慢的问题

    一.有条件的可以翻墙. 二.在C:\Windows\System32\drivers\etc修改host文件 如果没有权限,那么复制到桌面,添加以下内容再粘贴回去: # GitHub Start 19 ...

  2. 吴裕雄 Bootstrap 前端框架开发——Bootstrap 辅助类:元素浮动到右边

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  3. 在cnblog中试用Markdown

    参考: http://www.cnblogs.com/cmt/p/markdown.html https://www.cnblogs.com/cmt/p/markdown-latex.html htt ...

  4. swift4之String与NSString的区别与使用

    String是结构体,NSString是类,这是它们的根本区别. 在 Swift 中,结构体struct是值类型,String是结构体,所以也是值类型.值类型被赋予给一个变量.常量或者被传递给一个函数 ...

  5. Subtitles

    1. 字幕Subtitles 2. 字幕类型 3. 字幕格式 4. 常用文本字幕 5. 字幕编辑器 6. 字幕编辑器比较 1. 字幕Subtitles https://en.wikipedia.org ...

  6. JavaSwing标准对话框

    package test001; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import jav ...

  7. 闲谈“如何优化SSH框架的项目”

    使用struts框架的好处之一就是所有action类继承一个基类,将访问控制在基类中处理.2.所有的action类都继承自baseaction,一个资源对应一个action类.1.实现一个继承自str ...

  8. angularJS 获取数据及 排序

  9. [LeetCode] 326. Power of Three + 342. Power of Four

    这两题我放在一起说是因为思路一模一样,没什么值得研究的.思路都是用对数去判断. /** * @param {number} n * @return {boolean} */ var isPowerOf ...

  10. NO33 第6--7关题目讲解

    客户端(电脑)通过浏览器输入域名,先找hosts文件及本地dns缓存,若都没有,就找localDNS服务器,若没有,localDNF服务器找根服务器(全球13台的那个根”.“服务器),根就把.com这 ...