0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-10 07:58:52 +00:00
OI-codes/BZOJ/2257/2257.cpp

39 lines
641 B
C++

#include <iostream>
#include <map>
using std::cin;
using std::cout;
const char endl = '\n';
int n, k;
std::map<int, int> map;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
for (int i = 1, x; i <= n; i++) {
cin >> x;
for (int j = 1; j * j <= x; j++) {
if (x % j == 0) {
map[j]++;
if (j != x / j) map[x / j]++;
}
}
}
for (auto it = map.rbegin(); it != map.rend(); it++) {
if (it->second >= k) {
cout << it->first << endl;
exit(0);
}
}
return 0;
}