Start: Feb, 20, 2019 12:00:00
2018-2019 ACM集训队冬季集训第一次考核
End: Feb, 20, 2019 17:00:00
Time elapsed:
Time remaining:

Problem_ID: H
Result: Accepted
Time: 4566ms
Memory: 30140kB
Author: 2017212212098
In contest: 1260

#include "iostream"
#include "queue"
#include "algorithm"
#include "map"
#include "set"
using namespace std;
struct aka{
	long long len,num;
}b[500005];

int main(){
	map<long long,int> mm;
	int n,k;
	set<long long> sss;
	long long a[100005];
	long long maxx =0;
	scanf("%d%d",&n,&k);
	for(int i =1;i<=n;i++){
		scanf("%lld",&a[i]);
		for(int j =1;j<=10;j++){
			if(a[i]%j==0){
				sss.insert(a[i]/j);
				sss.insert(j);
			}
		}
		if(maxx<a[i])
			maxx = a[i];
	}
	sort(a,a+n);
	int t =1;
	int ans =0;
	a[n+1]=-1;
	for(int i=1;i<=n;i++){
		if(a[i]==a[i+1]){
			t++;
		}
		else{
			b[ans].len = t;
			b[ans].num = a[i];
			mm[a[i]] = t;
			ans++;
			t =1;
		}
	}
	int MAX = 0;
	int temp = 0;
	for(auto pos:sss){
		b[ans++].num = pos;
	}
	for(int i = 0;i<ans;i++){
		temp =0;
		for(int j = 1;j<=k;j++){
			if(j*b[i].num<=maxx&&j*b[i].num>0){
				if(mm.count(j*b[i].num))
					temp+=mm[j*b[i].num];
			}
			else {
				break;
			}
		}
		if(temp>MAX)
			MAX = temp;
	}
	printf("%d",MAX);
}