Codeforces 27 E Number With The Given Amount Of Divisors
来源:互联网 发布:访客网络要开启吗 编辑:程序博客网 时间:2024/06/06 14:06
题目链接:http://codeforces.com/problemset/problem/27/E
题 意:求因子个数为n的最小数。
思 路:这道题目分析一下,1018的不大,比264要小,所以这题可以枚举。
一个数 A 可以分解成 p1k1 * p2k2 * …… * pnkn 其中p为素数。这样分解之后,A的因子个数S = (k1+1) *( k2+1) * …… *( kn+1)然后用dfs枚举 + 剪枝。
代码如下:
#include <iostream>using namespace std;#include <string.h>#include <stdio.h>#include <climits>#include <algorithm>typedef __int64 LL;LL ans;LL n;const LL pr[16]={2,3,5,7,11,13,17,19,23,29,31};void DFS( LL k, LL num, LL now ){ if( num > n ) return; if( num == n && now < ans ) { ans = now; return; } for( int i = 1; i <= 64; i ++ ) { if( now * pr[k] <= ans ) { DFS( k+1, num*(i+1), now*=pr[k] ); } else break; }}const LL MAX = 1e18+9;int main(){ while( scanf ( "%I64d", &n ) != EOF ) { ans = MAX; DFS(0,1,1); printf("%I64d\n",ans); } return 0;}
1 0
- 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
- 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+数论)
- CodeForces - 27E Number With The Given Amount Of Divisors (反素数入门)
- [CodeForces 27E] 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
- CodeForces 27E Number With The Given Amount Of Divisors【反素数】
- codeforces 27E - Number With The Given Amount Of Divisors (数论 dfs)
- CodeForces - 27E Number With The Given Amount Of Divisors (DFS+数学)
- codeforces 27 E. 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(dfs)
- 寄售业务的SAP标准流程
- 【C++/数据结构】循环链表的基本操作
- poj2280--Amphiphilic Carbon Molecules(扫描线+极角排序+转换坐标)
- contiki_protothread源码
- Note For Linux By Jes(6)-正规表示法与文件格式化处理
- Codeforces 27 E Number With The Given Amount Of Divisors
- 机器学习实践 学习笔记1 Machine learning basics
- int main(int argc,char* argv[])详解
- openwrt 网关烧写程序
- 用 Java 技术创建 RESTful
- AMR音频编码器概述及文件格式分析
- 剑指offer面试题12-打印1到最大的n位数
- iOS懒加载
- 【C++/数据结构】双向链表的基本操作