Result: Accepted
Time: 1721ms
Memory: 38420kB
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int inf = 0x3f3f3f3f;
#define LL long long int
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
/*
const int MAXN = 300100;
struct Edge{
int to,next;
}edge[MAXN*2];
int head[MAXN],tot;
int top[MAXN];//top[v] 表示 v 所在的重链的顶端节点
int fa[MAXN];//父亲节点
int deep[MAXN];//深度
int num[MAXN];//num[v] 表示以 v 为根的子树的节点数
int p[MAXN];//p[v] 表示 v 对应的位置
int fp[MAXN];//fp 和 p 数组相反
int son[MAXN];//重儿子
int pos;
void init()
{
tot = 0;
memset(head,-1,sizeof(head));
pos = 1;//使用树状数组,编号从头 1 开始
memset(son,-1,sizeof(son));
}
void addedge(int u,int v){
edge[tot].to = v; edge[tot].next = head[u]; head[u] = tot++;
}
void dfs1(int u,int pre,int d){
deep[u] = d;
fa[u] = pre;
num[u] = 1;
for(int i = head[u];i != -1; i = edge[i].next){
int v = edge[i].to;
if(v != pre){
dfs1(v,u,d+1);
num[u] += num[v];
if(son[u] == -1 || num[v] > num[son[u]])
son[u] = v;
}
}
}
void getpos(int u,int sp){
top[u] = sp;
p[u] = pos++;
fp[p[u]] = u;
if(son[u] == -1) return;
getpos(son[u],sp);
for(int i = head[u];i != -1;i = edge[i].next){
int v = edge[i].to;
if( v != son[u] && v != fa[u])
getpos(v,v);
}
}
//树状数组
int lowbit(int x){
return x&(-x);
}
LL c[MAXN];
int n;
int sum(int i){
int s = 0;
while(i > 0)
{
s += c[i];
i -= lowbit(i);
}
return s;
}
void add(int i,LL val){
while(i <= n){
c[i] += val;
i += lowbit(i);
}
}
//u->v 的路径上点的值改变 val
void Change(int u,int v,int val){
int f1 = top[u], f2 = top[v];
int tmp = 0;
while(f1 != f2){
if(deep[f1] < deep[f2]){
swap(f1,f2);
swap(u,v);
}
add(p[f1],val);
add(p[u]+1,-val);
u = fa[f1];
f1 = top[u];
}
if(deep[u] > deep[v]) swap(u,v);
add(p[u],val);
add(p[v]+1,-val);
}
struct Node
{
LL x,y;
int ty;
}Q[300005];
*/
int n,k;
map<LL ,int>vis;
int main()
{
scanf("%d %d",&n,&k);
int ans=0;
for(int i=1;i<=n;i++)
{
LL x;
scanf("%lld",&x);
for(LL cnt=1;cnt<=k;cnt++)
{
if(cnt>x)break;
if(x%cnt==0)
{
vis[x/cnt]++;
ans=max(ans,vis[x/cnt]);
}
}
}
printf("%d\n",ans);
}