数论 CF27E Number With The Given Amount Of Divisors
求因子数一定的最小数(反素数)
#include<iostream>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<sstream>
#include<cstdio>
#define INF 0x3f3f3f3f
const int maxn = 1e3 + ;
const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;
using namespace std; //若取前17个素数,其乘积大于要求范围
ull p[] = { ,,,,,,,,,,,,,, }; ull ans;
ull n; //depth 当前在枚举第几个素数,num:当前因子数
//tmp:当前因子数量为num的时候的数值
//up:上一个素数的幂,这次应该小于等于这个幂次 void dfs(ull depth, ull tmp, ull num, ull up) {
if (num > n || depth >= ) return;
if (num == n && ans >= tmp) {
ans = tmp;
return;
}
for (int i = ; i <= up; i++) {
if (tmp / p[depth] > ans) return;
dfs(depth + , tmp = tmp * p[depth], num * (i + ), i);
}
} int main() {
while (scanf("%llu", &n) != EOF) {
ans = INF;
dfs(, , , );
printf("%llu", ans);
}
return ;
}
数论 CF27E 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 ...
- 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 搜索+数论
题目链接 首先要知道一个性质, 一个数x的因子个数等于 a1^p1 * a2^p2*....an^pn, ai是x质因子, p是质因子的个数. 然后就可以搜了 #include <iostrea ...
- 【数学】【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 ...
- Codeforces 27E. Number With The Given Amount Of Divisors (暴力)
题目链接:http://codeforces.com/problemset/problem/27/E 暴力 //#pragma comment(linker, "/STACK:1024000 ...
- 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的不大 ...
随机推荐
- PaperReading20200222
CanChen ggchen@mail.ustc.edu.cn VS-GAE Motivation: With the publication of NAS101, researchers can ...
- Linux进程通信方式
参考:https://www.cnblogs.com/yangykaifa/p/7295863.html
- 学习进度-11 RDD 编程初级实践
一. 请到本教程官网的“下载专区”的“数据集”中下载 chapter5-data1.txt,该数据集包含 了某大学计算机系的成绩,数据格式如下所示: Tom,DataBase,80 Tom,Algor ...
- java SHA1加密算法
package com.cn.test.rsa; import java.security.MessageDigest; import java.security.NoSuchAlgorithmExc ...
- Kubernetes——YAML文件
kubernetes——yaml文件的编写yaml文件的结尾后缀名.yaml或者.yml都能够识别.yaml文件就像脚本一样,可以放在任意的位置.编写yaml文件需要用到的帮助手册的查看: kubec ...
- Html5使用audio播放音乐
html代码 <audio id="myaudio" src="http://ws.stream.qqmusic.qq.com/C100003R74Cn0JR4O ...
- delphi窗体按钮灰化禁用
1.使最小化按钮变灰:setwindowlong(handle,gwl_style,getwindowlong(handle,gwl_style) and not ws_minimizeb ...
- 预备JS执行环境,预执行脚本
page.evaluateOnNewDocument(pageFunction, ...args) pageFunction <function|string> Function to b ...
- metasploit练习
复现ms08_067_netapi 使用模块 msf5 > use exploit/windows/smb/ms08_067_netapi 查看配置 msf5 exploit(windows/s ...
- 【LeetCode】排列硬币
[问题]你总共有 n 枚硬币,你需要将它们摆成一个阶梯形状,第 k 行就必须正好有 k 枚硬币.给定一个数字 n,找出可形成完整阶梯行的总行数.n 是一个非负整数,并且在32位有符号整型的范围内. [ ...