数论 CF27E Number With The Given Amount Of Divisors
求因子数一定的最小数(反素数)
- #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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论
题目链接 首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数. 然后就可以搜了 #include <iostrea ...
- 【数学】【CF27E】 Number With The Given Amount Of Divisors
传送门 Description 给定一个正整数\(n\),输出最小的整数,满足这个整数有n个因子 Input 一行一个整数\(n\) Output 一行一个整数,代表答案. Hint \(1~\leq ...
- codeforces 27 E. Number With The Given Amount Of Divisors(数论+dfs)
题目链接:http://codeforces.com/contest/27/problem/E 题意:问因数为n个的最小的数是多少. 题解:一般来说问到因数差不多都会想到素因子. 任意一个数x=(p1 ...
- Codeforces 27E. Number With The Given Amount Of Divisors (暴力)
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...
- 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 ...
- 大家一起做训练 第一场 E Number With The Given Amount Of Divisors
题目来源:CodeForce #27 E 题目意思和题目标题一样,给一个n,求约数的个数恰好为n个的最小的数.保证答案在1018内. Orz,这题训练的时候没写出来. 这道题目分析一下,1018的不大 ...
随机推荐
- 解决国内GitHub加载慢的问题
一.有条件的可以翻墙. 二.在C:\Windows\System32\drivers\etc修改host文件 如果没有权限,那么复制到桌面,添加以下内容再粘贴回去: # GitHub Start 19 ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 辅助类:元素浮动到右边
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 在cnblog中试用Markdown
参考: http://www.cnblogs.com/cmt/p/markdown.html https://www.cnblogs.com/cmt/p/markdown-latex.html htt ...
- swift4之String与NSString的区别与使用
String是结构体,NSString是类,这是它们的根本区别. 在 Swift 中,结构体struct是值类型,String是结构体,所以也是值类型.值类型被赋予给一个变量.常量或者被传递给一个函数 ...
- Subtitles
1. 字幕Subtitles 2. 字幕类型 3. 字幕格式 4. 常用文本字幕 5. 字幕编辑器 6. 字幕编辑器比较 1. 字幕Subtitles https://en.wikipedia.org ...
- JavaSwing标准对话框
package test001; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import jav ...
- 闲谈“如何优化SSH框架的项目”
使用struts框架的好处之一就是所有action类继承一个基类,将访问控制在基类中处理.2.所有的action类都继承自baseaction,一个资源对应一个action类.1.实现一个继承自str ...
- angularJS 获取数据及 排序
- [LeetCode] 326. Power of Three + 342. Power of Four
这两题我放在一起说是因为思路一模一样,没什么值得研究的.思路都是用对数去判断. /** * @param {number} n * @return {boolean} */ var isPowerOf ...
- NO33 第6--7关题目讲解
客户端(电脑)通过浏览器输入域名,先找hosts文件及本地dns缓存,若都没有,就找localDNS服务器,若没有,localDNF服务器找根服务器(全球13台的那个根”.“服务器),根就把.com这 ...