标签:i++ str tps main problems set temp pre for
1030 完美数列 (25分)
https://pintia.cn/problem-sets/994805260223102976/problems/994805291311284224
#include <iostream> #include <vector> #include <algorithm> typedef long long ll; using namespace std; int main() { int n; ll p; cin>>n>>p; vector<int> vec(n); for(int i=0;i<n;i++) cin>>vec[i]; int result=0,temp=0; sort(vec.begin(),vec.end()); for(int i=0;i<n;i++) { for(int j=i+result;j<n;j++) { if(vec[j]<=p*vec[i]) temp=j-i+1; if(temp>result) result=temp; else break; } } cout<<result; return 0; }
标签:i++ str tps main problems set temp pre for
原文地址:https://www.cnblogs.com/jianqiao123/p/12239100.html