Result: Accepted
Time: 1124ms
Memory: 39204kB
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
typedef long long LL;
int n, k;
LL a[100005];
map<LL, int>mmp;
map<LL, int>::iterator it;
int main()
{
scanf("%d %d", &n, &k);
for(int i = 1; i <= n;i++)
{
scanf("%lld", &a[i]);
}
sort(a+1,a+1+n);
for(int i = 1;i<=k;i++)
{
for(int j=1;j<=n;j++)
{
if(a[j]%i==0)mmp[a[j]/i]++;
}
}
int maxx = 0;
for(it = mmp.begin();it!=mmp.end();it++)
{
if(it->second>maxx)maxx = it->second;
}
printf("%d\n", maxx);
return 0;
}