mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-09 15:58:47 +00:00
CF27E Number With The Given Amount Of Divisors
https://www.luogu.com.cn/record/81585090
This commit is contained in:
parent
9ce4eac729
commit
5425a3bf86
36
Luogu/CF27E/CF27E.cpp
Normal file
36
Luogu/CF27E/CF27E.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
|
||||
|
||||
int n;
|
||||
long long ans = std::numeric_limits<long long>::max();
|
||||
|
||||
void dfs(long long now, int id, int max, int cnt) {
|
||||
if (cnt > n || now <= 0 || now > ans || id > 15) return;
|
||||
if (cnt == n) {
|
||||
ans = now;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 1; i <= max; i++) {
|
||||
dfs(now *= primes[id], id + 1, i, cnt * (i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n;
|
||||
|
||||
dfs(1, 0, 64, 1);
|
||||
|
||||
cout << ans << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user