E. Number With The Given Amount Of Divisors
2 seconds
256 megabytes
standard input
standard output
Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 1018.
The first line of the input contains integer n (1 ≤ n ≤ 1000).
Output the smallest positive integer with exactly n divisors.
4
6
6
12
思路:反素数;
(1)一个反素数的所有质因子必然是从2开始的连续若干个质数,因为反素数是保证约数个数为的这个数
尽量小
(2)同样的道理,如果,那么必有
1 #include<stdio.h>
2 #include<algorithm>
3 #include<iostream>
4 #include<string.h>
5 #include<queue>
6 #include<math.h>
7 #include<set>
8 #include<vector>
9 #include<string.h>
10 using namespace std;
11 typedef long long LL;
12 bool prime[100];
13 int ans[100];
14 LL minn = 1e18+10;
15 LL maxx = 1e18;
16 void dfs(LL n,int cn,int pre,int need,int cnt);
17 int main(void)
18 {
19 LL m,n;
20 int i,j;
21 int cn = 0;
22 memset(prime,0,sizeof(prime));
23 for(i = 2 ; i < 100 ; i++)
24 {
25 if(!prime[i])
26 {
27 ans[cn++] = i;
28 for(j = i; (i*j) <= 100 ; j++)
29 {
30 prime[i*j]=true;
31 }
32 }
33 }
34 int ak = 16;
35 while(scanf("%lld",&n)!=EOF)
36 {
37 minn = 1e18+10;
38 dfs(1,0,63,n,1);
39 printf("%lld\n",minn);
40 }
41 return 0;
42 }
43 void dfs(LL n,int cn,int pre,int need,int cnt)
44 {
45 if(cnt>need)return ;
46 if(cnt == need)
47 {
48 minn = min(minn,n);
49 return ;
50 }
51 LL ap = 1;
52 int i,j;
53 for(i = 1; i <= pre; i++)
54 { if(maxx/ap>=ans[cn])
55 ap*=ans[cn];
56 else return ;
57 if(maxx/n >= ap)dfs(n*ap,cn+1,pre,need,cnt*(1+i));
58 else return ;
59
60 }
61 }
E. 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 ...
- Codeforces 27E. Number With The Given Amount Of Divisors (暴力)
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...
- codeforces 27E . Number With The Given Amount Of Divisors 搜索+数论
题目链接 首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数. 然后就可以搜了 #include <iostrea ...
- 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 ...
- codeforces 27 E. Number With The Given Amount Of Divisors(数论+dfs)
题目链接:http://codeforces.com/contest/27/problem/E 题意:问因数为n个的最小的数是多少. 题解:一般来说问到因数差不多都会想到素因子. 任意一个数x=(p1 ...
- 数论 CF27E Number With The Given Amount Of Divisors
求因子数一定的最小数(反素数) #include<iostream> #include<string> #include<cmath> #include<cs ...
随机推荐
- centos 安装reids
1.安装tcl支持 yum install tcl 2.安装redis我们以最新的2.8.9为例 $ wget http://download.redis.io/releases/redis-2.8. ...
- 🚀 RabbitMQ课程发布-KuangStudy
RabbitMQ课程上线(44集) 视频教程地址:https://www.kuangstudy.com/course/detail/1323452886432944129 专栏地址:https://w ...
- A Child's History of England.12
Dunstan, Abbot of Glastonbury Abbey, was one of the most sagacious of these monks. He was an ingenio ...
- 【Android】我有放入Icon到mipmap,但不显示,只显示安卓机器人Icon(Android 8.0 图标适配)
首先,放上别人写的博客,而我自己的博客,只会写大概思路,给自己留给备忘 https://blog.csdn.net/guolin_blog/article/details/79417483 其实会发生 ...
- Android实现网络监听
一.Android Wifi常用广播 网络开发中主体会使用到的action: ConnectivityManager.CONNECTIVITY_ACTION WifiManager.WIFI_STAT ...
- Virtual Destructor
Deleting a derived class object using a pointer to a base class that has a non-virtual destructor re ...
- 【Linux】【Basis】【网络】网络相关的内核参数
Linux系统内核设置优化tcp网络,# vi /etc/sysctl.conf,添加以下内容 net.ipv4.tcp_syncookies = 1 表示开启SYN Cookies.当出现SYN等待 ...
- centos7.4 64位安装 redis-4.0.0
1. 下载 redis 包 链接:https://pan.baidu.com/s/1g1UE_GTreXoD9uOXB7G3HA 提取码:ug8p 2. 安装gcc.ruby .rubygems等环 ...
- Android CameraX 打开摄像头预览
目标很简单,用CameraX打开摄像头预览,实时显示在界面上.看看CameraX有没有Google说的那么好用.先按最简单的来,把预览显示出来. 引入依赖 模块gradle的一些配置,使用的Andro ...
- 玩转 Mockjs,前端也能跑的很溜
mockjs作用就是,生成随机模拟数据,拦截 ajax 请求,可以对数据进行增删改查.在生成数据时,我们就需要能够熟练使用 mock.js 的语法. Mockjs 的语法规范包括两部分:数据模板定 ...