1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <bits/stdc++.h>
using namespace std;
const int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 79, 83, 89, 97}, p_cnt = 24;
int n; int res_cnt, res_minx = 1e9;
void dfs(long long x, int cnt, int p, int lst_k) { if (cnt > res_cnt || (cnt == res_cnt && x < res_minx)) res_cnt = cnt, res_minx = x; else if (cnt <= res_cnt && x >= res_minx) return; if (p >= p_cnt) return;
long long acc = 1; int k = 0; while (x * acc <= n && k <= lst_k) { dfs(x * acc, cnt * (k + 1), p + 1, k); acc *= primes[p]; k++; } }
int main() { cin >> n; dfs(1, 1, 0, 1e9); cout << res_minx << endl; cerr << res_cnt << endl; }
|