您的位置:首页 > 其它

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
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: