#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void *b)
{
return *(long long*)a-*(long long*)b;
}
int main(void)
{
int N,p;
int M,m;
scanf("%d%d",&N,&p);
int i;
long num[N];
for(i = 0 ;i < N; i ++)
{
scanf("%ld",num + i);
}
qsort(num,N,sizeof(long),compare);
long min;
int count;
int temp = 0;
int j = 0;
for(i = 0; i < N; i ++)
{
min = num[i];
count = 0;
//j = i;//测试点四
while(min*p >= num[j] && j<N)
{
j++;
}
count = j - i;
if(count > temp)
{
temp = count;
}
}
printf("%d",temp);
return 0;
}
PTA1030-C语言-完美数列
最新推荐文章于 2024-08-13 16:02:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)