0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 17:56:28 +00:00

P4571 [JSOI2009] 瓶子和燃料

https://www.luogu.com.cn/record/89424858
This commit is contained in:
Baoshuo Ren 2022-10-11 09:37:28 +08:00
parent 77bdd51811
commit 7c0dfb9906
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

38
Luogu/P4571/P4571.cpp Normal file
View File

@ -0,0 +1,38 @@
#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;
}