codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论
首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数。
然后就可以搜了
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define pb(x) push_back(x)
#define ll long long
#define mk(x, y) make_pair(x, y)
#define lson l, m, rt<<1
#define mem(a) memset(a, 0, sizeof(a))
#define rson m+1, r, rt<<1|1
#define mem1(a) memset(a, -1, sizeof(a))
#define mem2(a) memset(a, 0x3f, sizeof(a))
#define rep(i, n, a) for(int i = a; i<n; i++)
#define fi first
#define se second
typedef pair<int, int> pll;
const double PI = acos(-1.0);
const double eps = 1e-;
const int mod = 1e9+;
const int inf = ;
const int dir[][] = { {-, }, {, }, {, -}, {, } };
int n, f[], prime[], cnt;
ll ans = 1e18+;
void dfs(int pos, int num, ll val) {
if(pos>)
return ;
if(num>n)
return ;
if(num == n) {
ans = min(ans, val);
return ;
}
for(int i = ; i<=; i++) {
val *= prime[pos];
if(val>ans)
break;
dfs(pos+, num*(i+), val);
}
}
int main()
{
cin>>n;
for(int i = ; i<; i++) {
if(!f[i]) {
for(int j = i+i; j<; j+=i) {
f[j] = ;
}
prime[cnt++] = i;
}
}
dfs(, , );
cout<<ans<<endl;
return ;
}
codeforces 27E . 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 27E. Number With The Given Amount Of Divisors (暴力)
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...
- codeforces 27 E. Number With The Given Amount Of Divisors(数论+dfs)
题目链接:http://codeforces.com/contest/27/problem/E 题意:问因数为n个的最小的数是多少. 题解:一般来说问到因数差不多都会想到素因子. 任意一个数x=(p1 ...
- 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 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的不大 ...
- 【数学】【CF27E】 Number With The Given Amount Of Divisors
传送门 Description 给定一个正整数\(n\),输出最小的整数,满足这个整数有n个因子 Input 一行一个整数\(n\) Output 一行一个整数,代表答案. Hint \(1~\leq ...
- 数论 CF27E Number With The Given Amount Of Divisors
求因子数一定的最小数(反素数) #include<iostream> #include<string> #include<cmath> #include<cs ...
随机推荐
- radio与checkbox
最近一直在学习Javascript与asp.net MVC4,每天都在跟着书学习.这样总感觉自己看的很抽象,没有点实际的意义.而且,每次看的东西很容易忘记,所以打算在这里记录自己的学习笔记. Java ...
- SET STATISTICS IO和SET STATISTICS TIME 在SQL Server查询性能优化中的作用
近段时间以来,一直在探究SQL Server查询性能的问题,当然也漫无目的的查找了很多资料,也从网上的大神们的文章中学到了很多,在这里,向各位大神致敬.正是受大神们无私奉献精神的影响,所以小弟也作为回 ...
- hbase namespace问题
如果遇到进入shell之后HMaster自动挂掉的问题,并且master的log里出现“TableExistsException: hbase:namespace”字样,很可能是更换了Hbase的版本 ...
- UILabel头文件常见属性
text : default is nil 文本属性,默认值是 nil @property(nullable, nonatomic,copy) NSString *text; font : defau ...
- js & jq 加载js
最近做项目中, 经常要写js代码的, 从纯前端人员, 到我们这边的过度, 每个人写的风格都不一样, 大概整理了一下有这么几种 1.1 $(document).ready(function(){}); ...
- JavaScript 对象扩展代码
JavaScript 扩展代码 更具需要写的几个扩展. 扩展核心自执行函数 Object.extend /** * 对象扩展体 参数是 {属性|方法:属性值|方法体} * 只执行实现 * * 实例对基 ...
- jchat:linux聊天程序2:MySQL
该软件使用的数据库为MySQL,因为它免费.开源,在linux下几乎就是最好的选择. 首先要在mysql中root用户新建数据库并赋权给本用户: create database jchat; gran ...
- 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法(android)
final double x_pi = 3.14159265358979324 * 3000.0 / 180.0; public GeoPoint bd_encrypt(GeoPoint point) ...
- jQuery学习-事件之绑定事件(七)
今天来说说事件中的handlers方法中的一个片段 1 matches[ sel ] = handleObj.needsContext ? 2 jQuery( sel, this ).in ...
- node.js介绍
官网说明: Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable ...