1030 完美数列 (25 分)
#include <iostream> #include <algorithm> using namespace std; int main(){ int n, m, max = 1, arr[100005]; cin >> n >> m; for (int i = 0; i < n; i++) cin >> arr[i]; sort(arr, arr + n); for (int j = 0; j < n; j++){ for (int k = j + max; k < n; k++){ if (arr[j] * m >= arr[k]){ if (k - j + 1 > max) max = k - j + 1; } else break; } } cout << max << endl; return 0; }