Codeforces 27E. Number With The Given Amount Of Divisors (暴力)

时间:2023-03-08 16:35:23

题目链接:http://codeforces.com/problemset/problem/27/E

暴力

 //#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 1e5 + ;
int a[];
LL ans, p[] = {, , , , , , , , , , }, limit = 1e18; void dfs(int num, int len) {
if(num == ) {
LL res = ;
for(int i = ; i <= len; ++i) {
for(int j = ; j < a[i]; ++j) {
if(limit / p[i] <= res) {
return ;
}
res *= p[i];
}
}
ans = min(ans, res);
return ;
}
for(int i = ; i <= num; ++i) {
if(num % i == ) {
a[len + ] = i;
dfs(num / i, len + );
}
}
} int main()
{
int n;
cin >> n;
if(n == ) {
cout << << endl;
return ;
} else if(n == ) {
cout << << endl;
return ;
}
ans = limit;
for(int i = ; i <= n; ++i) {
if(n % i == ) {
a[] = i;
dfs(n/i, );
}
}
cout << ans << endl;
return ;
}