Codeforces Beta Round #27-E. Number With The Given Amount Of Divisors
2016-09-01 15:05
609 查看
原题链接
E. Number With The Given Amount Of Divisors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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.
Input
The first line of the input contains integer n (1 ≤ n ≤ 1000).
Output
Output the smallest positive integer with exactly n divisors.
Examples
input
output
input
output
这道题的求解方法和求反素数相同
E. Number With The Given Amount Of Divisors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
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.
Input
The first line of the input contains integer n (1 ≤ n ≤ 1000).
Output
Output the smallest positive integer with exactly n divisors.
Examples
input
4
output
6
input
6
output
12
这道题的求解方法和求反素数相同
#include <bits/stdc++.h> #define INF 1e18 using namespace std; typedef long long ll; int p[10] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}; ll ans = INF; int n; void dfs(int depth, ll temp, int num){ if(num == n && ans > temp){ ans = temp; return ; } for(int i = 1;; i++){ if(ans / p[depth] < temp|| (num*(i+1)) > n) break; dfs(depth+1, temp *= p[depth], num*(i+1)); } } int main(){ scanf("%d", &n); dfs(0, 1, 1); cout << ans << endl; return 0; }
相关文章推荐
- Mysql 主键是UUID查询上一条和下一条的实现
- WCF wsHttpBinding in SoapUI
- ajax跨域请求
- Nginx源代码分析之accept(十六)
- 代码笔记 | ajax实现服务器与浏览器长连接的功能
- 大概总结了一下jQuery的一些基础知识点
- 2
- iOS 保持界面流畅的技巧
- 前端小工具
- Qt之进程间通信(共享内存)
- leetcode:sort:Maximum Gap(164)
- C++中typename关键字的使用方法和注意事项
- 报错 Error: Permission denied to access property "href"
- 选择有益于性能的列类型
- Rabbitmq梳理
- RxJava 与 Retrofit 结合的最佳实践
- bitMap处理工具类
- selenium 安装与 chromedriver安装
- 元数据
- iOS:使用Github托管自己本地的项目代码方式三(命令行方式: Terminal Line)