PAT 1030 完美数列
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=100010;
int n,p,a[maxn];
typedef long long LL;
int main()
{
cin>>n>>p;
int i;
for(i=0;i<n;i++){
cin>>a[i];
}
sort(a,a+n);
int ans=1;
for(i=0;i<n;i++){
int j=upper_bound(a+i+1,a+n,(LL)a[i]*p)-a;
ans=max(ans,j-i);
}
cout<<ans<<endl;
return 0;
}