﻿PAT(B) 1030. 完美数列(25)-Ocrosoft

# PAT(B) 1030. 完美数列(25)

```10 8
2 3 20 4 5 1 6 7 8 9
```

```8
```

```#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define strend string::npos
#define ms(a) memset(a,0,sizeof(a))
#define rep(a,v,b) for(int a=v;a<b;a++)
#define repe(a,v,b) for(int a=v;a<=b;a++)
#define pre(a,v,b) for(int a=v;a>b;a--)
#define pree(a,v,b) for(int a=v;a>=b;a--)
#define lowbit(x) x&-x
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 27 + 10;
const int MOD = 1000000007;
int gcd(int a, int b)
{
if (!b)return a;
return gcd(b, a%b);
}
/*(◕‿‿◕)(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
/*(◕‿‿◕) 签订契约,成为马猴烧酒吧 (◕‿‿◕)*/
/*(◕‿‿◕)(◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕) (◕‿‿◕)*/
using namespace std;
int main()
{
LL n, m; cin >> n >> m;
LL v[100010];
for (int i = 0; i < n; i++)
scanf("%lld", &v[i]);
sort(v, v + n);
int ans = 1;
for (int j = 0; j < n; j++)
{
for (int i = j + ans; i < n; i++)
{
if (v[i]<=v[j] * m)
{
if (i - j + 1>ans)ans = i - j + 1;
}
else break;
}
}
printf("%d\n", ans);
return 0;
}
```