美文网首页
1030 完美数列 (25 分)

1030 完美数列 (25 分)

作者: 79d12e22ec53 | 来源:发表于2019-04-30 10:47 被阅读0次

此题只有23分,测试点5暂未通过

#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a, const *b)
{
    return *(int *)a - *(int *)b;
}

int main()
{
    int N, p, flag=0, i=0, j=0, count=0;
    scanf("%d %d", &N, &p);

    int a[100001];

    for(i=0; i<N; i++)
    {
        scanf("%d", &a[i]);
    }

    qsort(a, N, sizeof(a[0]), cmp);
    for(i=0; i<N; i++)
    {
        for(j=i+count; j<N; j++)
        {
            if(a[i]*p < a[j])
                break;
            if((j-i+1) > count)
                count = (j-i+1);
        }
    }
    printf("%d", count);
}

相关文章

网友评论

      本文标题:1030 完美数列 (25 分)

      本文链接:https://www.haomeiwen.com/subject/kuemnqtx.html