CF Number With The Given Amount Of Divisors
来源:互联网 发布:js blob转成base64 编辑:程序博客网 时间:2024/06/08 19:39
题意:
给出一个数n,求出因子的个数为n的最小的数。
思路:
首先要知道反素数的概念:对于任何正整数x,起约数的个数记做g(x).例
如g(1)=1,g(6)=4.如果某个正整数x满足:对于任意i(0 < i < x ),都有g(i) < g(x)
则称x为 反素数
可以得出:
1. 一个反素数的因子必然是从2连续开始的,目的是为了保证约数为x的数
n最小。
2. 这个数每个因子乘的次数,以非增的顺序。
所以这道题,可以利用素数来打一个表,并且用dfs的方式去搜索每一种情况。
#include <bits/stdc++.h>using namespace std;typedef long long LL;const LL INF = 1e18; //注意这里int p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};LL n;LL ans;void dfs(LL dept,LL tmp,LL num){ if(num > n) return ; if(num == n && ans > tmp) ans = tmp; for(int i = 1;i <= 63; i++) { if(ans / p[dept] < tmp) break; //剪枝 dfs(dept+1,tmp *= p[dept],num*(i+1)); //num的次数需要乘以i+1 }}int main(){ //freopen("in.txt","r",stdin); while(cin>>n) { ans = INF; dfs(0,1,1); cout<<ans<<endl; } return 0;}
0 0
- CF 27E Number With The Given Amount Of Divisors
- CF Number With The Given Amount Of Divisors
- CF-27E - Number With The Given Amount Of Divisors(枚举+dfs)
- CF27.E. Number With The Given Amount Of Divisors
- 27E - Number With The Given Amount Of Divisors
- Codeforces 27E - Number With The Given Amount Of Divisors
- Codeforces 27E Number With The Given Amount Of Divisors
- Codeforces 27 E Number With The Given Amount Of Divisors
- Codeforces27E Number With The Given Amount Of Divisors
- CodeForces 27E Number With The Given Amount Of Divisors
- codeforces 27E Number With The Given Amount Of Divisors
- zoj2562 More Divisors && CF27E. Number With The Given Amount Of Divisors(反素数)
- codeforces 27E E. Number With The Given Amount Of Divisors(dp+数论)
- CodeForces - 27E Number With The Given Amount Of Divisors (反素数入门)
- Ccodeforces 27E Number With The Given Amount Of Divisors(数论+搜索)
- [CodeForces 27E] Number With The Given Amount Of Divisors (数论 + 反素数)
- Codeforeces 27 E Number With The Given Amount Of Divisors(反素数)
- day4 CodeForces 27E Number With The Given Amount Of Divisors
- 常见grub分辨率过低问题以及修改grub界面颜色
- Java面试笔试题大汇总(最全+详细答案)
- ios开发之NSProcessInfo
- memory_get_usage和var_dump函数
- POJ 1039 Pipe 笔记
- CF Number With The Given Amount Of Divisors
- GLEW环境配置X86 , X64
- 我为什么要学习python
- Codeforces Round #411 A.Fake NP (思维题)
- 漫谈程序员系列:怎样成为技术达人
- hdu 3065 病毒侵袭持续中
- redis
- 负数为何在内存中以补码的形式存在?
- jqgrid学习笔记