#include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; const long long MOD = 1e9+7; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int divide[100000]; vector sieve(int n) { for (int i = 0; i < n + 1; i++) divide[i] = 1; vector is_prime(n + 1, true); for (int i = 2; i <= n; i++) { if (!is_prime.at(i)) continue; is_prime.at(i) = true; divide[i] = i; for (int j = i + i; j <= n; j += i) { is_prime.at(j) = false; divide[j] = i; } } vector res; for (int i = 2; i <= n; i++) if (is_prime.at(i)) res.push_back(i); return res; } map prime_factor(int n) { map res; while (1 < n) { res[divide[n]]++; n /= divide[n]; } return res; } int main() { int n, k; cin >> n >> k; sieve(n); int max_div = 0; int ans = -1; auto nps = prime_factor(n); for (int i = 1; i < n; i++) { auto ps = prime_factor(i); int common_prime = 0; for (auto np: nps) common_prime += min(ps[np.first], np.second); //cout << i << " " << common_prime << endl; if (common_prime < k) continue; int d = 1; for (auto p: ps) d *= (p.second + 1); if (max_div < d) { max_div = d; ans = i; } } cout << ans << endl; }