codeforces 27 E. Number With The Given Amount Of Divisors(反素数)
来源:互联网 发布:数据挖掘的技术基础 编辑:程序博客网 时间:2024/06/16 09:59
题意:
求最小的约数个数为n的数
解题思路:
反素数经典问题。这题要求的就是反素数,因为反素数的质因子一定是连续的,所以可以dfs枚举在连续几个质因子上的个数,即枚举种t1,t2,t3,每一个素因子的幂,来算出当前的数的因子个数,对于等于n的我们更新一下答案,使答案更小即可。
更形象一点的还是看acdreamers的博客吧,看到搜索树的图就很好理解了。
代码:
#include <bits/stdc++.h>using namespace std;const unsigned long long inf=~0ULL;int p[16] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; int n;unsigned long long ans;void dfs(int dept, unsigned long long tmp, int num){ if(num>n)return; if(num==n){ans=min(tmp, ans);return;} for(int i=0; i<=63; i++) { if(inf/p[dept]<tmp)break; dfs(dept+1, tmp*=p[dept], num*(i+2)); } return;}int main(){ cin>>n; ans=inf; dfs(0, 1, 1); cout<<ans<<endl;}
阅读全文
0 0
- CodeForces - 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(反素数)
- codeforces 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
- CodeForces 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(反素数)
- CodeForce 27E: Number With The Given Amount Of Divisors(求反素数)
- CF 27E Number With The Given Amount Of Divisors
- 27E - Number With The Given Amount Of Divisors
- codeforces 27E E. Number With The Given Amount Of Divisors(dp+数论)
- zoj2562 More Divisors && CF27E. Number With The Given Amount Of Divisors(反素数)
- day4 CodeForces 27E Number With The Given Amount Of Divisors
- Codeforces Beta Round #27-E. Number With The Given Amount Of Divisors
- hdu 3549 Flow Problem
- 关于初次搭建环境切换老版本出现错误gcc: error: unrecognized command line option ‘-mthumb’的解决方案
- 蓝桥杯 BEGIN-3 入门训练 圆的面积
- Intellij Idea 中hibernate 反向生成实体
- Ethernet PHY芯片AR8035驱动
- codeforces 27 E. Number With The Given Amount Of Divisors(反素数)
- 开机logo目录
- Linux中的文件描述符与打开文件之间的关系
- Jquery图片上传本地预览
- jquery实现点击table行变色且选中该行的radio
- linux下创建用户并且限定用户主目录
- Linux下控制环境变量
- 将MATLAB的.m脚本转化为.exe文件
- android kotlin基础(二)-基本类型